setReadable function missing information in clusterProfiler
1
0
Entering edit mode
ltb47 • 0
@0424aadc
Last seen 21 months ago
United States

Hello! I'm an undergrad working in a genetics lab right now and I'm trying to learn how to use clusterProfiler for a dot plot I'm trying to make! I've just finished up using compareCluster on two groups of genes I'm analyzing, and I'm trying to continue the process using the setReadable function. However, whenever I enter the command, the same error pops up. Does anyone know what I can do to get setReadable to run? I'm very new to R and am a bit stumped as to how to solve this issue. Any and all help would be super appreciated. Thanks for your time and understanding, and hopefully talk to someone soon!

-Lola

st <-clusterProfiler::compareCluster(genes, fun = "enrichKEGG",organism="dre",pvalueCutoff=0.05)st <- clusterProfiler::setReadable(st, "org.Dr.eg.db", keyType = "ENTREZID") Error in .testForValidKeys(x, keys, keytype, fks) : 'keys' must be a character vector

clusterProfiler • 1.4k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 32 minutes ago
United States

The error you see comes from AnnotationDbi::select and indicates that the items in your genes object aren't character. Here's an example

> library(clusterProfiler)
> data(gcSample)
> sapply(gcSample, class)
         X1          X2          X3          X4          X5          X6 
"character" "character" "character" "character" "character" "character" 
         X7          X8 
"character" "character" 

## convert to numeric

> gcSample <- lapply(gcSample, as.numeric)
> sapply(gcSample, class)
       X1        X2        X3        X4        X5        X6        X7        X8 
"numeric" "numeric" "numeric" "numeric" "numeric" "numeric" "numeric" "numeric" 

## Note that I am messing things up as an example. The gene IDs should be character!!!

> xx <- compareCluster(gcSample, fun="enrichKEGG",
                          organism="hsa", pvalueCutoff=0.05)
> z <- setReadable(xx, "org.Hs.eg.db", "ENTREZID")
Error in .testForValidKeys(x, keys, keytype, fks) : 
  'keys' must be a character vector

## Let's fix it

> gcSample <- lapply(gcSample, as.character)
> xx <- compareCluster(gcSample, fun="enrichKEGG",
                          organism="hsa", pvalueCutoff=0.05)
> z <- setReadable(xx, "org.Hs.eg.db", "ENTREZID")
> 

## Works now

Ideally you would have read the help page and that would have like, you know, helped. Unfortunately, here's what it says

Arguments:

geneClusters: a list of entrez gene id. Alternatively, a formula of
          type 'Entrez~group' or a formula of type 'Entrez | logFC ~
          group' for "gseGO", "gseKEGG" and "GSEA".

Which is not particularly helpful. Entrez Gene IDs are conventionally numeric, but when using the OrgDb packages they have to be character. However! There is an example that you can look at (which I used for the example above), and you could see what is in gcSample and compare to what you have and then figured out what you needed because they differ.

R help tends to be pretty terse, and it's a learned skill to be able to read and interpret. Hopefully this example provides one indication of how that's done.

ADD COMMENT

Login before adding your answer.

Traffic: 790 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6