comparison goseq.r @ 5:bbcf5f7f2af2 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/goseq commit 2dffcdff171ebf695ef0fc7eb8f8264f0d132115
author iuc
date Mon, 28 Jan 2019 04:27:40 -0500
parents ae39895af5fe
children 67c29afac85f
comparison
equal deleted inserted replaced
4:ae39895af5fe 5:bbcf5f7f2af2
132 # capture the sampling progress so it doesn't fill stdout 132 # capture the sampling progress so it doesn't fill stdout
133 zz <- file("/dev/null", open = "wt") 133 zz <- file("/dev/null", open = "wt")
134 sink(zz) 134 sink(zz)
135 GO.samp=goseq(pwf, genome = genome, id = gene_id, method="Sampling", repcnt=repcnt, use_genes_without_cat = use_genes_without_cat, gene2cat=go_map) 135 GO.samp=goseq(pwf, genome = genome, id = gene_id, method="Sampling", repcnt=repcnt, use_genes_without_cat = use_genes_without_cat, gene2cat=go_map)
136 sink() 136 sink()
137 137
138 GO.samp$p.adjust.over_represented = p.adjust(GO.samp$over_represented_pvalue, method=p_adj_method) 138 GO.samp$p.adjust.over_represented = p.adjust(GO.samp$over_represented_pvalue, method=p_adj_method)
139 GO.samp$p.adjust.under_represented = p.adjust(GO.samp$under_represented_pvalue, method=p_adj_method) 139 GO.samp$p.adjust.under_represented = p.adjust(GO.samp$under_represented_pvalue, method=p_adj_method)
140 write.table(GO.samp, sampling_tab, sep="\t", row.names = FALSE, quote = FALSE) 140 write.table(GO.samp, sampling_tab, sep="\t", row.names = FALSE, quote = FALSE)
141 # Compare sampling with wallenius 141 # Compare sampling with wallenius
142 if (make_plots == TRUE) { 142 if (make_plots == TRUE) {
154 cats_title <- gsub("GO:","", args$fetch_cats) 154 cats_title <- gsub("GO:","", args$fetch_cats)
155 # modified from https://bioinformatics-core-shared-training.github.io/cruk-summer-school-2018/RNASeq2018/html/06_Gene_set_testing.nb.html 155 # modified from https://bioinformatics-core-shared-training.github.io/cruk-summer-school-2018/RNASeq2018/html/06_Gene_set_testing.nb.html
156 pdf("top10.pdf") 156 pdf("top10.pdf")
157 for (m in names(results)) { 157 for (m in names(results)) {
158 p <- results[[m]] %>% 158 p <- results[[m]] %>%
159 top_n(10, wt=-p.adjust.over_represented) %>% 159 top_n(10, wt=-over_represented_pvalue) %>%
160 mutate(hitsPerc=numDEInCat*100/numInCat) %>% 160 mutate(hitsPerc=numDEInCat*100/numInCat) %>%
161 ggplot(aes(x=hitsPerc, 161 ggplot(aes(x=hitsPerc,
162 y=substr(term, 1, 40), # only use 1st 40 chars of terms otherwise squashes plot 162 y=substr(term, 1, 40), # only use 1st 40 chars of terms otherwise squashes plot
163 colour=p.adjust.over_represented, 163 colour=over_represented_pvalue,
164 size=numDEInCat)) + 164 size=numDEInCat)) +
165 geom_point() + 165 geom_point() +
166 expand_limits(x=0) + 166 expand_limits(x=0) +
167 labs(x="% DE in category", y="Category", colour="adj. P value", size="Count", title=paste("Top over-represented categories in", cats_title), subtitle=paste(m, " method")) + 167 labs(x="% DE in category", y="Category", colour="P value", size="Count", title=paste("Top over-represented categories in", cats_title), subtitle=paste(m, " method")) +
168 theme(plot.title = element_text(hjust = 0.5), plot.subtitle = element_text(hjust = 0.5)) 168 theme(plot.title = element_text(hjust = 0.5), plot.subtitle = element_text(hjust = 0.5))
169 print(p) 169 print(p)
170 } 170 }
171 dev.off() 171 dev.off()
172 } 172 }