Any trick to use "tximport" for converting a simple read count table ?
1
0
Entering edit mode
@akira-imamoto-11332
Last seen 7.7 years ago
USA/Chicago/University of Chicago

Hi, 

I'm hoping to use "tximport" to convert an RNA-Seq count data file for downstream analysis such as DESeq2. But I got an error as you can see below. I think everything I have is current (R3.3.1 etc). Any input will be much appreciated !! 

> datafileName <- "test.txt"  ## Replace the file name with the correct one
> table=read.delim(datafileName,header=T)
> 
> countsCol=colnames(table[,4:11])
> abundanceCol=colnames(table[,12:ncol(table)])
> RefSeqID=table[,3]
> Symbol=table[,2]
> tx2gene = data.frame(RefSeqID,Symbol)
> txin = tximport(datafileName, type="none", tx2gene = tx2gene, countsCol = countsCol, 
+                 abundanceCol=abundanceCol, lengthCol=NULL, txIdCol=NULL, 
+                 importer = read_tsv)
reading in files
1 Error in .subset2(x, i, exact = exact) : 
  attempt to select less than one element in get1index
tximport • 2.0k views
ADD COMMENT
1
Entering edit mode
@mikelove
Last seen 6 hours ago
United States
No this is not a use case for tximport. How did you make the count matrix? You should be able to use DESeqDataSetFromMatrix() straight away.
ADD COMMENT
0
Entering edit mode

Thank you very much for quick reply. I was trying to find a solution to my problem with DESeqDataSetFromMatrix(). I tried but it did not take a matrix as you can see below. Only way so far was to put count columns without the row name column (in this case Symbol). What am I doing wrong?

> datafileName <- "test.txt"  ## Replace the file name with the correct one
> table=read.delim(datafileName,header=T)
> 
> table=as.matrix(table[,c(2,5:12)]) ## column2 is "GeneSymbol";columns 5-12 are raw counts
> head(table)
     Symbol     MEF258   MEF258OHT MEF284   MEF284OHT MEF285   MEF285OHT MEF286   MEF286OHT
[1,] "BC021785" "     0" "     4"  "     0" "     0"  "     0" "     0"  "     0" "      1"
[2,] "Eea1"     "  3756" "  3527"  "  4339" "  3835"  "  3951" "  3831"  "  3619" "   5891"
[3,] "Adgrg6"   "  5887" "  5151"  "  4659" "  3134"  "  4463" "  5453"  "  3299" "   6849"
[4,] "Osbpl8"   "  5712" "  7739"  "  9810" " 10208"  "  3767" "  4675"  "  2923" "   6016"
[5,] "Ttc41"    "    15" "    42"  "    24" "    25"  "    10" "    36"  "    19" "     65"
[6,] "Mars"     "  6214" "  4115"  "  4704" "  2539"  "  5166" "  5006"  "  4325" "   8964"
> 
> cellid <- rep( c("1", "2", "3", "4"), each=2) 
> cellid=as.factor(cellid)
> treatment=rep(c(0, 1), 4)
> condition=as.factor(treatment)
> condition=relevel(condition, ref="0")
> meta = data.frame(cellid, condition)
> meta
  cellid condition
1      1         0
2      1         1
3      2         0
4      2         1
5      3         0
6      3         1
7      4         0
8      4         1
> 
> d <- DESeqDataSetFromMatrix(countData=table, colData = meta, design = ~condition)
Error in `rownames<-`(`*tmp*`, value = c("Symbol", "MEF258", "MEF258OHT",  : 
  invalid rownames length
ADD REPLY
0
Entering edit mode

Sorry! I found a solution myself for the input for DESeqDataSetFromMatrix(). Simple matrix didn't work, but adding rownames to a count-data-only table solved it.

tablex=as.matrix(table[,c(5:12)]) ## column3 is "RefSeqID";columns 5-12 are raw counts
rownames(tablex)=table[,3]

Thanks for taking time for your reply!

ADD REPLY
1
Entering edit mode

You got it. countData should be only a matrix of counts.

The correct error message was not coming through due to some recent code additions.

I've fixed the error message in the next version to say:

Error: ncol(countData) == nrow(colData) is not TRUE

ADD REPLY

Login before adding your answer.

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