Thanks, I tried this and it works.
Hi, I´m trying to do a dotplot using data from KEGG. I have my data represented, but I don´t want the species name in the X axis. My comand is:
kegg_gene_list = sort(kegg_gene_list, decreasing = TRUE)
kegg_gene_list = sort(kegg_gene_list, decreasing = TRUE)
kegg_organism = "mmu"
kk2 <- gseKEGG(geneList = kegg_gene_list,
organism = kegg_organism,
pvalueCutoff = 0.9,
pAdjustMethod = "none",
keyType = "ncbi-geneid")
kk2x <- setReadable(kk2, 'org.Mm.eg.db', 'ENTREZID')
dotplot(kk2x, showCategory=15, font.size=9, label_format= 100, title = "Enriched Pathways" , split=".sign") + facet_grid(.~.sign).
And I get
2 answers
If you want to stick with the native clusterProfiler plotting functions you should be able to modify the slot holding pathway names.
kk2x@result$Description <- gsub(kk2x@result$Description, pattern="\\s-\\sMus.+$", replacement="")
It's not ideal to modify slots directly, so the more proper alternative would be to convert it into a data.frame with as.data.frame(kk2x) and manually make the plot with ggplot2. Just know that slot names are not guaranteed to be documented in package updates, so may break in the future.
If you're able to get the data from this function (some packages use returnData = FALSE by default) then you can easily do this in ggplot and add the following:
kegg_gene_list <- kegg_gene_list %>% str_split(" - ", simplify=TRUE) %>% .[,1]
or
kegg_gene_list <- kegg_gene_list %>% str_replace(" - Mus musculus (house mouse)", "")
The first example is looking for the hyphen and splitting the character vector then selecting the first chunk which corresponds to your pathway. The second is directly replacing the hyphen and species with an empty character. Functionally equivalent, but the latter requires manipulation if you were to change species.
Thank you, I tried first the other answer (rpolicastro).
Log in to answer this question.