Dswede43
Dswede43

Reputation: 351

Error: cannot coerce type 'environment' to vector of type 'character' while using goProfiles package in R

I'm trying to complete a gene ontology (GO) analysis on a list of Entrez genes. I've installed the goProfiles package as well as the orgPackage org.Hs.eg.db.

I've tried to build a basic functional profile for my list of Entrez genes using the following code:

library(goProfiles)
library(org.Hs.eg.db)

entrez <- c(567, 6280, 1915, 3106, 60, 4512, 3043, 3107, 2495, 3133)
    
GO <- basicProfile(entrez, idType = "Entrez", onto = "BP", level = 2, 
orgPackage = org.Hs.eg.db, na.rm = T)

But I get the following error message:

Error in as.vector(x, "character") : cannot coerce type 'environment' to vector of type 'character'

Why am I having this issue? entrez is not defined as a 'character', its defined as 'numeric'.

Upvotes: 0

Views: 336

Answers (1)

xilliam
xilliam

Reputation: 2269

The documentation for goProfiles::basicProfile says this about its orgProfile argument:

Name of a Bioconductor's organism annotations package ('org.Xx-eg-db'). This field must be provided if the gene list passed to the function is either a character vector of 'Entrez' (NCBI) identifiers or a character vector of probe names.

Notice that it shows 'org.Xx-eg-db' in quotes. So try quoting your orgPackage input as follows.

library(goProfiles)
library(org.Hs.eg.db)

entrez <- c(567, 6280, 1915, 3106, 60, 4512, 3043, 3107, 2495, 3133)

GO <- basicProfile(entrez, idType = "Entrez", 
                   onto = "BP", level = 2, 
                   orgPackage = "org.Hs.eg.db", na.rm = T)

> basicProfile(entrez, idType = "Entrez", 
               +                    onto = "BP", level = 2, 
               +                    orgPackage = "org.Hs.eg.db", na.rm = T)

$BP
Description       GOID Frequency
5                                    behavior GO:0007610         1
12                        biological adhesion GO:0022610         4
20                           biological phase GO:0044848         0
29                      biological regulation GO:0065007         9
31                          biomineralization GO:0110148         0
7                    carbohydrate utilization GO:0009758         0
9                          carbon utilization GO:0015976         0
8                            cellular process GO:0009987        10
30                             detoxification GO:0098754         2
15                      developmental process GO:0032502         6
16                                     growth GO:0040007         1
2                       immune system process GO:0002376         8
19 interspecies interaction between organisms GO:0044419         5
27 intraspecies interaction between organisms GO:0051703         0
26                               localization GO:0051179        10
17                                 locomotion GO:0040011         2
6                           metabolic process GO:0008152         9
28                     multi-organism process GO:0051704         0
14           multicellular organismal process GO:0032501         7
23  negative regulation of biological process GO:0048519         4
10                       nitrogen utilization GO:0019740         0
4                      phosphorus utilization GO:0006794         0
18                               pigmentation GO:0043473         0
22  positive regulation of biological process GO:0048518         6
24           regulation of biological process GO:0050789         9
1                                reproduction GO:0000003         0
11                       reproductive process GO:0022414         0
25                       response to stimulus GO:0050896        10
21                           rhythmic process GO:0048511         0
13                                  signaling GO:0023052         6
3                          sulfur utilization GO:0006791         0

Upvotes: 1

Related Questions