WGCNA connecting trait data
1
0
Entering edit mode
@jemaxfield-14002
Last seen 7.1 years ago

Hello, I am trying to analyze some RNASeq data using the WCGNA package. For the most part it works fine but I can't seem to connect my trait data with my expression data.

I have a normalized expression matrix with 39 samples and a lot of contigs. My data is a developmental series with 3-16 samples at each stage of development. The "trait" data is just the developmental stage. So I have a trait file with "Stage" (numbered 0-5) and "Individual". I added X's before the individual names in both files, because they were just numbers. When I try and connect the traits with the expression data I get a problem with the rownames.

The code I am using and error are:

>allTraits = traitData[, c(1:2) ]
>    dim(allTraits) 
[1] 39  2
>    names(allTraits)
[1] "Individual"   "Stage_number"
>   Eep_samples=rownames(datExpr)
>   traitRows = match(Eep_samples, allTraits$Individual)
>   datTraits = allTraits[traitRows, -1]
>   rownames(datTraits) = allTraits[traitRows, 1]
Error in `rownames<-`(`*tmp*`, value = c("X221_quant", "X267_quant", "X320_quant",  : 
  attempt to set 'rownames' on an object with no dimensions

I am just learning R. Am missunderstanding what the code is doing and am actually deleting all the trait data? I assume the -1, 1 are defining where the row names are...

Any help would be appreciated! Thank you!

> sessionInfo() 

R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

 

WGCNA wgcna rownames • 2.1k views
ADD COMMENT
2
Entering edit mode
@peter-langfelder-4469
Last seen 14 days ago
United States

Add a "drop = FALSE" to this line: datTraits = allTraits[traitRows, -1]

datTraits = allTraits[traitRows, -1, drop = FALSE]

Your allTraits contains only 2 columns; when you remove the first one, you are left with just one column and R converts that into a single vector unless you add the drop = FALSE argument.

HTH

Peter

ADD COMMENT
0
Entering edit mode

Thank you so much! That solved the problem. 

Jessica

ADD REPLY

Login before adding your answer.

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