Explore objects in R (ChiPseeker)
6
0
Entering edit mode
6.0 years ago

Hello there!

I've an object that describes the genomic distribution of my ChIPPeaks: Annotated peaks generated by ChIPseeker 16887/16887 peaks were annotated Genomic Annotation Summary:

             Feature  Frequency
9           Promoter 80.2392373
4             5' UTR  0.8704921
3             3' UTR  0.7875881
1           1st Exon  0.9237875
7         Other Exon  1.4093682
2         1st Intron  5.6019423
8       Other Intron  2.5996329
6 Downstream (<=300)  0.4026766
5  Distal Intergenic  7.1652751

This is a list of the PeakAnno object, the structure of each of them is:

    str(peakAnnoList)[[1]]

By looking at the str of the object:

    .. ..@ detailGenomicAnnotation:'data.frame':  16887 obs. of  9 variables:
  .. .. ..$ genic            : logi [1:16887] FALSE TRUE TRUE FALSE TRUE TRUE ...
  .. .. ..$ Intergenic       : logi [1:16887] TRUE FALSE FALSE TRUE FALSE FALSE ...
  .. .. ..$ Promoter         : logi [1:16887] FALSE TRUE TRUE TRUE TRUE TRUE ...
  .. .. ..$ fiveUTR          : logi [1:16887] FALSE TRUE TRUE FALSE TRUE TRUE ...
  .. .. ..$ threeUTR         : logi [1:16887] FALSE FALSE FALSE FALSE FALSE FALSE ...
  .. .. ..$ Exon             : logi [1:16887] FALSE TRUE TRUE FALSE TRUE TRUE ...
  .. .. ..$ Intron           : logi [1:16887] FALSE TRUE TRUE FALSE TRUE TRUE ...
  .. .. ..$ downstream       : logi [1:16887] FALSE FALSE FALSE FALSE FALSE FALSE ...
  .. .. ..$ distal_intergenic: logi [1:16887] TRUE FALSE FALSE FALSE FALSE FALSE ...

This is a list of true and false and the number of the TRUE shall be the number of peaks I am searching for. How can I count all of of those TRUE in every @ detailGenomicAnnotation of peakAnnolist? Thank u!

R ChIPseeker bioconductor • 3.2k views
ADD COMMENT
0
Entering edit mode

Please format code/output with the code button (1010101) in the editor, it makes it a lot easier to read and understand. In addition, it is difficult to answer this question without additional information as to what type of object it is, code used to generate it, etc.

as.data.frame() can be used to coerce many objects to a dataframe, so you could try that, but it really depends on the type of object.

ADD REPLY
0
Entering edit mode

Oh sure, I am sorry. I't is a chip seeker object (PeakAnno) Used to perform a genome distribution graph.

ChIPseeker 16887/16887 peaks were annotated Genomic Annotation Summary: Feature Frequency 9 Promoter 80.2392373 4 5' UTR 0.8704921 3 3' UTR 0.7875881 1 1st Exon 0.9237875 7 Other Exon 1.4093682 2 1st Intron 5.6019423 8 Other Intron 2.5996329 6 Downstream (<=300) 0.4026766 5 Distal Intergenic 7.1652751

I just wanted to understand what is in an particular "r" object. when I look at it in R studio I can see it is very similar to the R object of deseq2 (dds) for instance.

ADD REPLY
0
Entering edit mode

I think what I search for is in the str command:

str(peakAnnoList[[1]])
Formal class 'csAnno' [package "ChIPseeker"] with 7 slots
  ..@ anno                   :Formal class 'GRanges' [package "GenomicRanges"] with 7 slots
  .. .. ..@ seqnames       :Formal class 'Rle' [package "S4Vectors"] with 4 slots
  .. .. .. .. ..@ values         : Factor w/ 20 levels "chr1","chr10",..: 1 2 3 4 5 6 7 8 9 10 ...
  .. .. .. .. ..@ lengths        : int [1:20] 1448 1355 2267 910 906 851 1163 751 1293 709 ...
  .. .. .. .. ..@ elementMetadata: NULL
  .. .. .. .. ..@ metadata       : list()
  .. .. ..@ ranges         :Formal class 'IRanges' [package "IRanges"] with 6 slots
  .. .. .. .. ..@ start          : int [1:25534] 4491695 4496226 4496653 4543925 4571460 4785191 4807453 4857347 5018514 5082862 ...
  .. .. .. .. ..@ width          : int [1:25534] 1884 295 1007 224 387 801 859 1360 2247 853 ...
  .. .. .. .. ..@ NAMES          : NULL
  .. .. .. .. ..@ elementType    : chr "ANY"
  .. .. .. .. ..@ elementMetadata: NULL
  .. .. .. .. ..@ metadata       : list()
  .. .. ..@ strand         :Formal class 'Rle' [package "S4Vectors"] with 4 slots
  .. .. .. .. ..@ values         : Factor w/ 3 levels "+","-","*": 3
  .. .. .. .. ..@ lengths        : int 25534
  .. .. .. .. ..@ elementMetadata: NULL
  .. .. .. .. ..@ metadata       : list()
  .. .. ..@ seqinfo        :Formal class 'Seqinfo' [package "GenomeInfoDb"] with 4 slots
  .. .. .. .. ..@ seqnames   : chr [1:20] "chr1" "chr10" "chr11" "chr12" ...
  .. .. .. .. ..@ seqlengths : int [1:20] 195471971 130694993 122082543 120129022 120421639 124902244 104043685 98207768 94987271 90702639 ...
  .. .. .. .. ..@ is_circular: logi [1:20] NA NA NA NA NA NA ...
  .. .. .. .. ..@ genome     : chr [1:20] "mm10" "mm10" "mm10" "mm10" ...
  .. .. ..@ elementMetadata:Formal class 'DataFrame' [package "S4Vectors"] with 6 slots
  .. .. .. .. ..@ rownames       : NULL
  .. .. .. .. ..@ nrows          : int 25534
  .. .. .. .. ..@ listData       :List of 16

And goes on

ADD REPLY
0
Entering edit mode

so that means you could, for example, use the command above for that list object:

x <- as.data.frame(peakAnnoList[[1]])
ADD REPLY
0
Entering edit mode
6.0 years ago

Pretty sure x <- as.data.frame(PeakAnno) will work for that object, if I remember correctly. Been a while since I used ChIPseeker. That should let you peruse what it's doing more closely, but in general, each row is a peak with the gene annotation info slapped on, which is what the graph is being generated from.

ADD COMMENT
0
Entering edit mode

Thanks Jared for answering! I've tried what u suggest, if I do it:

 x <- as.data.frame(peakAnnoList)

Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 25534, 19869, 16887, 21478, 26122

I think it doesn't work because this object has 5 samples in it!

ADD REPLY
0
Entering edit mode

This probably means that it is a list of these objects, so lapply(peakAnnoList, as.data.frame, head) might be worth a try. If you want more concrete help, you should update your question to include the result of str(peakAnnoList) and what exactly it is you're trying to do/to see.

ADD REPLY
0
Entering edit mode

Yes, this is exactly right. I did not realize it was a list of them.

ADD REPLY
0
Entering edit mode
6.0 years ago

I tried this option and there u go:

lapply(peakAnnoList, as.data.frame, head)

Error in as.data.frame.csAnno(X[[i]], ...) : 'row.names' must be NULL or a character vector

I am so sorry, I didn't want to bother so much 😅, was thinking was easy.

I updated the question.

ADD COMMENT
0
Entering edit mode
6.0 years ago

Updated main post with new info

ADD COMMENT
0
Entering edit mode

Please post such comments as comments or update the question with them (which it seems you've done here). You can answer your own question, of course, which is still useful for the community, but this isn't an answer and will likely be moved to our thread above whenever a mod stumbles upon it. This also makes the question a lot easier to follow and will yield better answers.

From the limited info here, I expect one of these answers from StackOverflow will answer your question. Or as you said, you can just use the frequencies and total number of rows to calculate how many are in each group.

ADD REPLY
0
Entering edit mode

I'll move it in the main post. I'm very sorry. I'm still getting used to the forum rules : (

ADD REPLY
0
Entering edit mode
6.0 years ago

Updated the main post with new info

ADD COMMENT
0
Entering edit mode
6.0 years ago

Does table(peakAnnoList[[1]]@detailGenomicAnnotation$genic) get you what you want? I think part of the issue here is that we don't really have the object you're dealing with, so it's a little tricky to give you the precise code. You'll have to do some fiddling apparently or go back to the documentation of the package and see if they give any pointers in their vignette.

ADD COMMENT
0
Entering edit mode
table(peakAnnoList[[1]]@detailGenomicAnnotation$genic)
FALSE  TRUE 
4762 20772

This is exactly what I was searching for! I can apply it for every detailGenomicAnnotation and every object in peakAnnoList and the job is done!

: ) THANK YOU GUYS!

ADD REPLY

Login before adding your answer.

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