Skip to content
Snippets Groups Projects
Commit 3b74ba3b authored by nfontrod's avatar nfontrod
Browse files

R/figure.R R/topGO_analysis.R: add correction of p-values

parent 71ec2d50
No related branches found
No related tags found
No related merge requests found
...@@ -17,10 +17,10 @@ build_figure <- function(top_go_result, go_term_type, outfile) { ...@@ -17,10 +17,10 @@ build_figure <- function(top_go_result, go_term_type, outfile) {
} }
top_go_result$fish <- as.numeric(gsub("< ", "", top_go_result$fish)) top_go_result$fish <- as.numeric(gsub("< ", "", top_go_result$fish))
top_go_result <- top_go_result %>% top_go_result <- top_go_result %>%
mutate(sigv = -log10(pvalue), mutate(sigv = -log10(padj),
significance = ifelse(sigv < 400, sigv, 400), significance = ifelse(sigv < 400, sigv, 400),
ft = paste(GO.ID, ":", Term)) %>% ft = paste(GO.ID, ":", Term)) %>%
filter(pvalue <= 0.05) %>% filter(padj <= 0.05) %>%
arrange(desc(significance)) arrange(desc(significance))
fig <- ggplot(top_go_result, mapping = aes( fig <- ggplot(top_go_result, mapping = aes(
x = significance, y = fct_reorder(ft, significance), x = significance, y = fct_reorder(ft, significance),
......
...@@ -55,8 +55,7 @@ get_gene_list <- function(de_table, regulation, alpha, log2fc_threshold, ...@@ -55,8 +55,7 @@ get_gene_list <- function(de_table, regulation, alpha, log2fc_threshold,
#' @import org.Hs.eg.db #' @import org.Hs.eg.db
#' @export #' @export
top_go_analysis <- function(de_table, kind, id_kind, go_term_type, regulation, top_go_analysis <- function(de_table, kind, id_kind, go_term_type, regulation,
top, alpha, log2fc_threshold, basemean_threshold top, alpha, log2fc_threshold, basemean_threshold) {
) {
if (kind == "tibble") { if (kind == "tibble") {
gene_list <- get_gene_list( gene_list <- get_gene_list(
de_table, regulation, alpha, log2fc_threshold, de_table, regulation, alpha, log2fc_threshold,
...@@ -90,9 +89,10 @@ top_go_analysis <- function(de_table, kind, id_kind, go_term_type, regulation, ...@@ -90,9 +89,10 @@ top_go_analysis <- function(de_table, kind, id_kind, go_term_type, regulation,
considered_genes <- length(gene_list[gene_list == 1]) considered_genes <- length(gene_list[gene_list == 1])
results.f <- runTest(GOdata, algorithm = "classic", statistic = "fisher") results.f <- runTest(GOdata, algorithm = "classic", statistic = "fisher")
res <- GenTable(GOdata, fish = results.f, orderBy = "fish", topNodes = top) res <- GenTable(GOdata, fish = results.f, orderBy = "fish", topNodes = top)
df <- as.data.frame(sort(score(results.f))[1:top]) df <- as.data.frame(sort(score(results.f)))
colnames(df) <- c("pvalue") colnames(df) <- c("pvalue")
df$GO.ID <- rownames(df) df$padj <- p.adjust(df$pvalue, method = "fdr")
df$GO.ID <- rownames(head(df, n=top))
res <- res %>% left_join(df) res <- res %>% left_join(df)
return(list( return(list(
res = res, nb_gene = considered_genes, nb_go_gene = nb_go_gene, res = res, nb_gene = considered_genes, nb_go_gene = nb_go_gene,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment