Issue with DESeq2: Unable to create colData because "Error in data[[rowvar]]"
1
0
Entering edit mode
5.6 years ago
catglen012 ▴ 10

Hello! I am not able to load my "ColData" (which contains information about my samples) on r and I am not sure why. I was able to load my "CountData" though.

> countData <- as.matrix(read.csv(file.choose(), row.names = "gene_id"))
> colData <- read.table(file.choose(),header=TRUE, row.names = "gene_id")

Error in data[[rowvar]] : attempt to select less than one element in get1index.

I tried to do the following also but it said Population is not found when it is actually there:

> colData <- read.table(file.choose(),header=TRUE, row.names = gene_id,Stage,Sex,Isolate,Population,Stage_Sex)

Error in match.arg(numerals) : object 'Population' not found

This is how some of the first lines in my CountData look like using TextWrangler (I could not copy the whole thing here because I have about 30 samples:

gene_id,Alsk_10-5_B150f_Gam_1,Alsk_10-5_B150f_Gam_2,Alsk_10-5_B150f_Gam_3
MSTRG.20438,160107,112757,141604,219222,98860,221610,104534,108994,117852,123897,162138
MSTRG.19848,1401,1286,1533,972,538,941,1514,1317,1642,603,764,758,1155,930,1269,1000

This is how the some of the first lines in my ColData look like using TextWrangler:

gene_id,Stage,Sex,Isolate,Population,Stage_Sex
Alsk_10.5_B150f_Gam_1,Gametophore,Female,Alsk_B150f,Alaska,Gametophore_Female
Alsk_10.5_B150f_Gam_2,Gametophore,Female,Alsk_B150f,Alaska,Gametophore_Female
RNA-Seq r R DESeq2 • 4.2k views
ADD COMMENT
3
Entering edit mode
5.6 years ago

Hello and good evening,

You need to do:

colData <- read.table(file.choose(),header=TRUE, row.names = "gene_id", sep=",")

I have added sep=","

--------------------------------------------

as.matrix(read.csv("counts.test", row.names = "gene_id"))
            Alsk_10.5_B150f_Gam_1 Alsk_10.5_B150f_Gam_2 Alsk_10.5_B150f_Gam_3
MSTRG.20438                160107                112757                    NA
MSTRG.19848                  1401                  1286                  1533


read.table("colData.test", header=TRUE, row.names = "gene_id", sep=",")
                            Stage    Sex    Isolate Population
Alsk_10.5_B150f_Gam_1 Gametophore Female Alsk_B150f     Alaska
Alsk_10.5_B150f_Gam_2 Gametophore Female Alsk_B150f     Alaska
                               Stage_Sex
Alsk_10.5_B150f_Gam_1 Gametophore_Female
Alsk_10.5_B150f_Gam_2 Gametophore_Female

Kevin

ADD COMMENT
0
Entering edit mode

Thank you Kevin!

I tried changing my file from a .csv file to a .txt file and that worked! I was able to upload my data and obtain:

all(rownames(colData) %in% colnames(countData)) [1] TRUE countData <- countData[, rownames(colData)] all(rownames(colData) == colnames(countData)) [1] TRUE

I was wondering if you have an idea as in why the .txt format worked vs. the .csv ?

ADD REPLY
0
Entering edit mode

read.table() is the base function here, with default of sep="", i.e., whitespace (tabs, spaces, etc).

read.csv() is a wrapper of read.table() and has sep=",".

For further information, type ?read.table from within R

For reading in larger data, you may consider fread() from data.table package.

ADD REPLY

Login before adding your answer.

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