Error in ReactomePA
2
0
Entering edit mode
Ram ▴ 20
@ram-6189
Last seen 6.3 years ago

Hi all,

I am using R package ReactomePA for enrichment analysis. But I am getting this type of error after reading each command perfectly also.

Error in x[seq_len(n)] : object of type 'S4' is not subsettable

Thanks!

Any help ?

r reactomepa • 3.3k views
ADD COMMENT
0
Entering edit mode

Please EDIT YOUR QUESTION to include a reproducible example. For instance, when I try your code I get

> x[seq_len(n)]
Error: object 'x' not found

because obviously in my session R doesn't know what x or n is!

ADD REPLY
0
Entering edit mode

Here is the part of code with head of (l):

x <- enrichPathway(gene=l,organism="mouse",pvalueCutoff=0.05, readable=T)

head(l)

[1] "30054"  "237898" "217026" "12833"  "27364"  "22158" 

> head(x)

Error in x[seq_len(n)] : object of type 'S4' is not subsettable

 head(summary(x))

[1] ID          Description GeneRatio   BgRatio     pvalue      p.adjust   

[7] qvalue      Count      

<0 rows> (or 0-length row.names)

ADD REPLY
0
Entering edit mode

From the (excellent and pretty!) vignette, it looks like you mean head(summary(x)), and I guess from GuanghuangYu's answer there are no enriched results.

For what it's worth, you can discover the class and  methods available on 'x' with

> class(x)
[1] "enrichResult"
attr(,"package")
[1] "DOSE"
> methods(class=class(x))
[1] [[        barplot   cnetplot  dotplot   plot      show      summary  
[8] upsetplot
see '?methods' for accessing help and source code

which might help identify what operations you can perform.

ADD REPLY
0
Entering edit mode
Guangchuang Yu ★ 1.2k
@guangchuang-yu-5419
Last seen 27 days ago
China/Guangzhou/Southern Medical Univer…
> require(ReactomePA)
> g = as.character(1:20)
> x=enrichPathway(g)
> x
#
# over-representation test
#
#...@organism      human
#...@ontology      Reactome
#...@keytype      ENTREZID
#...@gene      chr [1:20] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" ...
#...pvalues adjusted by 'BH' with cutoff <0.05
#...0 enriched terms found
'data.frame':    0 obs. of  9 variables:
 $ ID         : chr
 $ Description: chr
 $ GeneRatio  : chr
 $ BgRatio    : chr
 $ pvalue     : num
 $ p.adjust   : num
 $ qvalue     : num
 $ geneID     : chr
 $ Count      : int
#...Citation
  Guangchuang Yu, Qing-Yu He. ReactomePA: an R/Bioconductor package for
  reactome pathway analysis and visualization. Molecular BioSystems
  2016, 12(2):477-479

 

>  #...0 enriched terms found

If you print the object, it will show you that there is not enriched term found.

 

> head(summary(x))
[1] ID          Description GeneRatio   BgRatio     pvalue      p.adjust
[7] qvalue      geneID      Count
<0 rows> (or 0-length row.names)

`head(summary(x))` also give you such information.

 

This is a valid result and the output object, x, also contains information of the data that is accessible.

> x@gene
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15"
[16] "16" "17" "18" "19" "20"
> x@organism
[1] "human"

 

> head(x)

Error in x[seq_len(n)] : object of type 'S4' is not subsettable

You can't use `head(x)` to print subset of `S4` object if the method `[` is not defined for the object.  This is why `head(x)` throw the following error (error exists no matter there have terms enriched or not). 

 

 

 

ADD COMMENT
0
Entering edit mode
Guangchuang Yu ★ 1.2k
@guangchuang-yu-5419
Last seen 27 days ago
China/Guangzhou/Southern Medical Univer…

OK, I think re-define `[` can save some typing. `[`, `[[`, `head` and `tail` methods will work for `enrichResult` and `gseaResult` object. I just commit it to github.

If you want to access `summary(x)[1,]`, you can use `x[1,]` or `x[1]`.


> require(ReactomePA)
Loading required package: ReactomePA
> data(geneList)
> gene = names(geneList)[1:200]
> x = enrichPathway(gene)
> x[1]
             ID Description GeneRatio  BgRatio       pvalue     p.adjust
1640170 1640170  Cell Cycle    49/114 497/6749 1.932903e-26 6.475225e-24
              qvalue
1640170 5.167972e-24
                                                                                                                                                                                                                                                                  geneID
1640170 8318/55143/55388/991/2305/9493/1062/4605/9133/10403/7153/23397/6241/11065/55355/220134/4751/79019/55839/890/983/54821/4085/9837/81930/81620/332/64151/9212/51659/1111/10112/6790/891/4174/9232/4001/4171/11004/993/990/5347/701/11130/79682/57405/2491/9700/5888
        Count
1640170    49
> x[1:2]
             ID         Description GeneRatio  BgRatio       pvalue
1640170 1640170          Cell Cycle    49/114 497/6749 1.932903e-26
69278     69278 Cell Cycle, Mitotic    45/114 408/6749 3.891472e-26
            p.adjust       qvalue
1640170 6.475225e-24 5.167972e-24
69278   6.518216e-24 5.202284e-24
                                                                                                                                                                                                                                                                  geneID
1640170 8318/55143/55388/991/2305/9493/1062/4605/9133/10403/7153/23397/6241/11065/55355/220134/4751/79019/55839/890/983/54821/4085/9837/81930/81620/332/64151/9212/51659/1111/10112/6790/891/4174/9232/4001/4171/11004/993/990/5347/701/11130/79682/57405/2491/9700/5888
69278                        8318/55143/55388/991/2305/9493/1062/4605/9133/10403/7153/23397/6241/11065/220134/4751/79019/55839/890/983/54821/4085/9837/81930/81620/332/64151/9212/51659/10112/6790/891/4174/9232/4171/11004/993/990/5347/701/11130/79682/57405/2491/9700
        Count
1640170    49
69278      45

 

ADD COMMENT
0
Entering edit mode

If you want to print the `head(summary(x))` or `tail(summary(x))` in your R console, you can use `head(x)` or `tail(x)`.

> head(x, 2)
             ID                             Description GeneRatio  BgRatio
1640170 1640170                              Cell Cycle    49/114 497/6749
69278     69278                     Cell Cycle, Mitotic    45/114 408/6749
              pvalue     p.adjust       qvalue
1640170 1.932903e-26 6.475225e-24 5.167972e-24
69278   3.891472e-26 6.518216e-24 5.202284e-24
                                                                                                                                                                                                                                                                  geneID
1640170 8318/55143/55388/991/2305/9493/1062/4605/9133/10403/7153/23397/6241/11065/55355/220134/4751/79019/55839/890/983/54821/4085/9837/81930/81620/332/64151/9212/51659/1111/10112/6790/891/4174/9232/4001/4171/11004/993/990/5347/701/11130/79682/57405/2491/9700/5888
69278                        8318/55143/55388/991/2305/9493/1062/4605/9133/10403/7153/23397/6241/11065/220134/4751/79019/55839/890/983/54821/4085/9837/81930/81620/332/64151/9212/51659/10112/6790/891/4174/9232/4171/11004/993/990/5347/701/11130/79682/57405/2491/9700
        Count
1640170    49
69278      45
> tail(x, 2)
           ID                   Description GeneRatio  BgRatio      pvalue
418594 418594 G alpha (i) signalling events     9/114 203/6749 0.007158604
73886   73886        Chromosome Maintenance     5/114  75/6749 0.008498797
         p.adjust     qvalue                                         geneID
418594 0.03931364 0.03137680 10874/3627/10563/6373/4283/2921/6364/9568/3576
73886  0.04592092 0.03665016                   55355/79019/55839/79682/2491
       Count
418594     9
73886      5

 

The input genes that belong to specific term can be accessed via `[[`.

> x[2]
         ID         Description GeneRatio  BgRatio       pvalue     p.adjust
69278 69278 Cell Cycle, Mitotic    45/114 408/6749 3.891472e-26 6.518216e-24
            qvalue
69278 5.202284e-24
                                                                                                                                                                                                                                           geneID
69278 8318/55143/55388/991/2305/9493/1062/4605/9133/10403/7153/23397/6241/11065/220134/4751/79019/55839/890/983/54821/4085/9837/81930/81620/332/64151/9212/51659/10112/6790/891/4174/9232/4171/11004/993/990/5347/701/11130/79682/57405/2491/9700
      Count
69278    45
> x[[x[2]$ID]]
 [1] "8318"   "55143"  "55388"  "991"    "2305"   "9493"   "1062"   "4605"
 [9] "9133"   "10403"  "7153"   "23397"  "6241"   "11065"  "220134" "4751"
[17] "79019"  "55839"  "890"    "983"    "54821"  "4085"   "9837"   "81930"
[25] "81620"  "332"    "64151"  "9212"   "51659"  "10112"  "6790"   "891"
[33] "4174"   "9232"   "4171"   "11004"  "993"    "990"    "5347"   "701"
[41] "11130"  "79682"  "57405"  "2491"   "9700"
>

 

These new features will be available in next release (expected Oct. 2016).

 

ADD REPLY
0
Entering edit mode

Dear Guangchuang Yu,

Thanks a lot for replying. But I am still not getting the effective results.

It will be really helpful. If can put more light on it. I am using ReactomePA package.

Here is my code which I am using: 

library(ReactomePA)

df =read.table("GO_Chip-seq.txt")

> head(df)

     ensembl_gene_id entrezgene                         name_1006 mgi_symbol

1 ENSMUSG00000000365      30054                         cytoplasm      Rnf17

2 ENSMUSG00000000365      30054                           nucleus      Rnf17

3 ENSMUSG00000000365      30054                   protein binding      Rnf17

4 ENSMUSG00000000365      30054                  zinc ion binding      Rnf17

5 ENSMUSG00000000365      30054             spermatid development      Rnf17

6 ENSMUSG00000000365      30054 protein homodimerization activity      Rnf17

f=df[,(“entrezgene")]

v <- na.omit(f)

g=unique(v)

l=as.character(g)

x <- enrichPathway(gene=g,organism="mouse",pvalueCutoff=0.05, readable=T)

ADD REPLY
0
Entering edit mode

As Martin said, please include a reproducible example.

Please EDIT YOUR QUESTION to include a reproducible example. For instance, when I try your code I get

> x[seq_len(n)]
Error: object 'x' not found

because obviously in my session R doesn't know what x or n is!

ADD REPLY
0
Entering edit mode

Below attached is the link to part of the file:

https://www.dropbox.com/s/wvp1lmvpprvkutm/file.txt?dl=0

After that I used the code :

library(ReactomePA)

df =read.table(“file.txt")

f=df[,(“entrezgene")]

v <- na.omit(f)

g=unique(v)

l=as.character(g)

x <- enrichPathway(gene=l,organism="mouse",pvalueCutoff=0.05, readable=T)

ADD REPLY
0
Entering edit mode

Here is what I get:

 

> x
#
# over-representation test
#
#...@organism      mouse
#...@ontology      Reactome
#...@keytype      ENTREZID
#...@gene      chr [1:7] "30054" "237898" "217026" "12833" "27364" "22158" ...
#...pvalues adjusted by 'BH' with cutoff <0.05
#...11 enriched terms found
'data.frame':    11 obs. of  9 variables:
 $ ID         : chr  "5991850" "5992181" "5992212" "5991298" ...
 $ Description: chr  "NCAM1 interactions" "Assembly of collagen fibrils and other multimeric structures" "Collagen biosynthesis and modifying enzymes" "NCAM signaling for neurite out-growth" ...
 $ GeneRatio  : chr  "1/2" "1/2" "1/2" "1/2" ...
 $ BgRatio    : chr  "34/7109" "40/7109" "58/7109" "59/7109" ...
 $ pvalue     : num  0.00954 0.01122 0.01625 0.01653 0.01681 ...
 $ p.adjust   : num  0.0378 0.0378 0.0378 0.0378 0.0378 ...
 $ qvalue     : num  0.00795 0.00795 0.00795 0.00795 0.00795 ...
 $ geneID     : chr  "Col6a1" "Col6a1" "Col6a1" "Col6a1" ...
 $ Count      : int  1 1 1 1 1 1 1 1 1 1 ...
#...Citation
  Guangchuang Yu, Qing-Yu He. ReactomePA: an R/Bioconductor package for
  reactome pathway analysis and visualization. Molecular BioSystems
  2016, 12(2):477-479

 

Make sure you are using the latest release version of ReactomePA, see <https://guangchuangyu.github.io/2016/07/how-to-bug-author/>.

ADD REPLY
0
Entering edit mode

I am using ReactomePA version 1.16.2 as mentioned in bioconductor

summary:

> sessionInfo()

R version 3.3.0 (2016-05-03)

Platform: x86_64-apple-darwin13.4.0 (64-bit)

Running under: OS X 10.10.5 (Yosemite)

 

locale:

[1] C

 

attached base packages:

[1] stats     graphics  grDevices utils     datasets  methods   base     

 

other attached packages:

[1] devtools_1.12.0   ReactomePA_1.16.2 DOSE_2.10.3      

 

loaded via a namespace (and not attached):

 [1] graph_1.50.0         igraph_1.0.1         Rcpp_0.12.5         

 [4] AnnotationDbi_1.34.3 magrittr_1.5         rappdirs_0.3.1      

 [7] BiocGenerics_0.18.0  splines_3.3.0        IRanges_2.6.0       

[10] munsell_0.4.3        colorspace_1.2-6     stringr_1.0.0       

[13] plyr_1.8.3           tools_3.3.0          parallel_3.3.0      

[16] grid_3.3.0           Biobase_2.32.0       gtable_0.2.0        

[19] DBI_0.4-1            withr_1.0.2          reactome.db_1.55.0  

[22] digest_0.6.9         GOSemSim_1.30.2      DO.db_2.9           

[25] reshape2_1.4.1       ggplot2_2.1.0        S4Vectors_0.10.1    

[28] memoise_1.0.0        qvalue_2.4.2         RSQLite_1.0.0       

[31] stringi_1.1.1        GO.db_3.3.0          scales_0.4.0        

[34] stats4_3.3.0         graphite_1.18.0     

 

ADD REPLY
0
Entering edit mode

Sorry, I can't reproduce your issue.

 

> require(ReactomePA)
> packageVersion('ReactomePA')
[1] ‘1.16.2’
> l
[1] "30054"  "237898" "217026" "12833"  "27364"  "22158"  "244668"
> x <- enrichPathway(gene=l,organism="mouse",pvalueCutoff=0.05, readable=T)
> head(summary(x), 2)
             ID                                                  Description
5991850 5991850                                           NCAM1 interactions
5992181 5992181 Assembly of collagen fibrils and other multimeric structures
        GeneRatio BgRatio      pvalue   p.adjust      qvalue geneID Count
5991850       1/2 34/7109 0.009543135 0.03776629 0.007950799 Col6a1     1
5992181       1/2 40/7109 0.011222469 0.03776629 0.007950799 Col6a1     1

 

ADD REPLY
0
Entering edit mode

Is it possible to know how in ReactomePA  it has the filter only for six or seven entries. It isn't possible to avail p-values for more entries ??

ADD REPLY

Login before adding your answer.

Traffic: 594 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