I have a cnetplot from running enrichment with kegg using clusterprofiler. I have scores input as the fold change but for each gene in the plot they are not varying in colour to show their difference in the fold change score.
My dataset is genes of entrez IDs and then each gene has a score from 0.5-0.9 (instead of fold change) that I want to be able to see by colour code in the plot, is this possible or does the foldchange parameter only use fold change measures?
For example my data looks like this:
Gene Score
1234 0.9
5678 0.83
91011 0.89
I am then coding to get the cnetplot with:
kegg_enrich <- enrichKEGG(gene = df$Gene,
organism = 'hsa',
pvalueCutoff = 0.05,
pAdjustMethod = 'fdr')
kegg <- setReadable(kegg_enrich, 'org.Hs.eg.db', 'ENTREZID')
kegg_genes <- kegg[,]
gene_list_scores <- df$Scores
gene_list_scores<-na.omit(gene_list_scores)
gene_list_scores = sort(gene_list_scores, decreasing = TRUE)
gene_of_interest <- dplyr::filter(kegg_genes, grepl('PTK2', geneID))
gene_of_interest<- enrichDF2enrichResult(gene_of_interest)
options(ggrepel.max.overlaps = 1000)
pother <- cnetplot(gene_of_interest, foldChange=gene_list_scores)
pother + scale_color_gradientn(name = "Score", colours = c("blue", "red"))
I am expecting the foldChange=gene_list_scores
to enable each gene in the plot to be coloured by their score in my data but the plot output looks like:
Probably you need to enable
colorEdge = TRUE
.Follow this link for detailed syntax.
Thank you for this, using
colorEdge = TRUE
alone only makes the lines coloured for some reason, but trying out the code from the link adds a colour scale legend, although still doesn't colour each gene point in - but from this I can see new ways to try out to get the syntax to work, thank you for your help!Hi, did you manage to figure this out? I am also stuck due to the same problem, would appreciate any help on figuring this out!
Hey guys! I think I may have an answer to your question. So to change the colour of the gene points, you need to supply a vector to
foldChange
. This vector needs to be a numeric vector named with the gene names. For example:Supply this vector to the function and you will get coloured gene nodes!
If you want to change the colours of the nodes, I know no intuitive way to do so, but during the summer of 2021 I found where the beige node colour is stored (see this link) and how to change it. This is how to change the colour in
enrichplot
v. 1.18.3:Hope this helps!