Search
Question: WGCNA connecting trait data
0
gravatar for je.maxfield
9 weeks ago by
je.maxfield0 wrote:

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

 

ADD COMMENTlink modified 9 weeks ago by Peter Langfelder1.3k • written 9 weeks ago by je.maxfield0
1
gravatar for Peter Langfelder
9 weeks ago by
United States
Peter Langfelder1.3k wrote:

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 COMMENTlink written 9 weeks ago by Peter Langfelder1.3k

Thank you so much! That solved the problem. 

Jessica

ADD REPLYlink written 9 weeks ago by je.maxfield0
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 2.2.0
Traffic: 143 users visited in the last hour