how to extract list in quantile in R
1
0
Entering edit mode
sat • 0
@ccbf0270
Last seen 6 weeks ago
italy
 I have a list of gene expression and i want to separate them based of their quantile in R.
How i can do this?
-quantile (gene_list)
  after that based of quantile the 5 list extracted 
gene_id  read_count
gene1  30
gene2 354
gene3  49
gene4 100
. .
.
 the output i want to be as below
list 1_quantile  0-1
list 2_quantile 1-20
list 3_quantile 20-50
list 4_quantile 50-100
list 5_quantile  >100
```
R quantile list • 800 views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 1 hour ago
United States

It appears that you are just asking a question that has nothing to do with Bioconductor tools (just because you are using gene expression data, doesn't mean it's a Bioconductor question). It's also not clear what you want? A list is a specific thing in R, and a gene list might mean a list of genes, or maybe you mean something entirely different. But anyway.

## fake data
> rn <- rnorm(1000)
> quantile(rn, seq(0,1,0.2))
        0%        20%        40%        60%        80%       100% 
-2.6974030 -0.8147699 -0.2391583  0.2748159  0.9112004  3.2960733 
> cuts <- cut(rn, quantile(rn, seq(0,1,0.2)), include.lowest = TRUE)
> levels(cuts)
[1] "[-2.7,-0.815]"   "(-0.815,-0.239]" "(-0.239,0.275]"  "(0.275,0.911]"  
[5] "(0.911,3.3]"  
> lst <- split(rn, cuts)
> sapply(lst, head)
     [-2.7,-0.815] (-0.815,-0.239] (-0.239,0.275] (0.275,0.911] (0.911,3.3]
[1,]    -1.8774472      -0.5442199     0.15592221     0.5735599    1.961777
[2,]    -0.9500052      -0.4153239    -0.23012671     0.5487853    1.838525
[3,]    -1.8244960      -0.5660583     0.09275705     0.8824427    1.557622
[4,]    -1.1705903      -0.6712830     0.21497970     0.5910672    2.210673
[5,]    -1.1879555      -0.4075969    -0.10534529     0.7041176    1.151611
[6,]    -0.9184985      -0.4060458     0.11778675     0.4087296    1.122461

One of those things might be what you are after.

ADD COMMENT
0
Entering edit mode

thank you, its good and work. is it possible the output list be with the gene_id? so it shows that each values depend of which gene_id!

ADD REPLY
0
Entering edit mode

The split function works on a data.frame as well as a vector. Please see ?split

ADD REPLY
0
Entering edit mode

Thank you, i would so grateful if you help more in this matter.

ADD REPLY

Login before adding your answer.

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