Question: Subsetting a tximport object
0
gravatar for scanchi
16 months ago by
scanchi0
scanchi0 wrote:

I have an tximport object with 628 files. I want to subset to remove some samples and maintain the tximport data structure.

str(txi_object)
List of 4
$ abundance          : num [1:56928, 1:628] 14.125 0 15.221 12.45 0.765 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:56928] "5S_rRNA" "5_8S_rRNA" "7SK" "A1BG" ...
  .. ..$ : chr [1:628] "20798913" "20914669" "50301125" "20149910" ...
$ counts             : num [1:56928, 1:628] 10.5 0 87.1 440 74.9 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:56928] "5S_rRNA" "5_8S_rRNA" "7SK" "A1BG" ...
  .. ..$ : chr [1:628] "20798913" "20914669" "50301125" "20149910" ...
$ length             : num [1:56928, 1:628] 15.1 24.2 116.4 718.5 1990.3 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:56928] "5S_rRNA" "5_8S_rRNA" "7SK" "A1BG" ...
  .. ..$ : chr [1:628] "20798913" "20914669" "50301125" "20149910" ...
$ countsFromAbundance: chr "no"

Final number of desired samples is 598 and I have the sample ids in a data frame. I tried mapply and ddply without much success. 

length(clean_samples$individualID)
[1] 598

Any ideas or suggestions would be helpful

regards

scanchi

p.s - I had to post the code as text as I was running into an language '"x" not supported issue.

 

tximport • 462 views
ADD COMMENTlink modified 16 months ago by jennietodd1410 • written 16 months ago by scanchi0
Answer: Subsetting a tximport object
0
gravatar for James W. MacDonald
16 months ago by
United States
James W. MacDonald50k wrote:

It's just three matrices with dim (ngenes x nsamples), plus one extra list item,  so you should be able to simply subset. Using the example for tximport and removing the last sample I would do

example(tximport)
z <- lapply(txi, function(x) if(is.matrix(x)) return(x[,1:5]) else return(x))
ADD COMMENTlink written 16 months ago by James W. MacDonald50k

Thank you James!

ADD REPLYlink written 16 months ago by scanchi0

Hi James,

I was wondering if you know how I could remove samples from the tximport object which are contained in a list of outliers? Thanks!

ADD REPLYlink modified 6 months ago • written 6 months ago by rodrigo.duarte880
1

If you are going to use edgeR or DESeq2 later, the easiest is to make the object and then subset that, e.g.

dds <- dds[,!colnames(dds) %in% outliers]
ADD REPLYlink written 6 months ago by Michael Love24k

Many thanks, Michael! This is super useful, as usual!

ADD REPLYlink written 6 months ago by rodrigo.duarte880
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 136 users visited in the last hour