How to access vector of certain column in phenotype data.
1
1
Entering edit mode
hashmi ▴ 10
@hashmi-8229
Last seen 8.8 years ago
Bangalore

I am interested to know how can i access vector of a column in phenotype data frame if  i don't know the conditions(groups) name in the phenotype data frame . I have phenotype information in the below file

Files                    Groups
GSM248652.CEL   A
GSM248655.CEL   A
GSM248238.CEL   A
GSM248650.CEL   B
GSM248651.CEL   B
GSM248661.CEL   C
GSM248660.CEL   C

Here in the above file i have Groups column and i normally access it and design a model matrix by

pdata = read.AnnotatedDataFrame("file.txt",sep="")
unique <- unique(pdata$Groups)
f <- factor(pdata$Groups, levels=unique)  
  design <- model.matrix(~0+f)
  colnames(design) <- unique 

Now i don't know the column name of conditions(groups), how to access and design a model matrix. Help appreciated.

r limma • 1.0k views
ADD COMMENT
2
Entering edit mode
@agaz-hussain-wani-7620
Last seen 6.1 years ago
India

According to the information pasted above, i think this should work.

You can read the file by read.table(), and then access the respective column vector to design a model matrix.

  pdata <- read.table("file.txt",header=TRUE)
  unique <- unique(pdata[,2])
  f <- factor(pdata[,2],levels=unique)
  design <- model.matrix(~0+f)
  colnames(design) <- unique 

 

ADD COMMENT
0
Entering edit mode

It works, thank you very much
 

ADD REPLY

Login before adding your answer.

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