Thursday, January 29, 2015

Importing normalized data

If I were better at R, I could just do all the math in R. But I am still better at identifying patterns using basic excel functions and color coding. So now, I have a dataset that I would like to import into R Studio.
    Norm.data <- read.csv("Z:/Data/Lung data/somdataT-norm-ig2b-TD.csv")
    Norm.data <- na.omit(Norm.data)
Turn it into a data matrix using
    Norm.data.m<- (data.matrix(Norm.data))
But there are not character row names?! I found two duplicate entries that may have caused errors in doing this and assigned them unique names. But I still got the error. Try setting names using this

     rownames(Norm.data) <- Norm.data[ ,1]
Simpler to use this function in one line (and works)

Norm.data.rn.m <- data.frame(Norm.data[,-1], row.names=Norm.data[,1])
Norm.data.m<- (data.matrix(Norm.data.rn.m))
Now I can finally apply the simple version of heatmap to view the data:

heatmap(Norm.data.m)

To look at only a subset of the data for the patients with overlapping data:

Norm.data.OL <- subset(Norm.data.m, select=c(2,4:8))
 heatmap(Norm.data.OL)

Other notes:

I am using the subset function to select parts of the data.

      x <- subset(somdataT, select = c(4:28))
     gene <-  subset(somdataT, select =c(2))

This can also be used conditionally to select above background 

somdat.bkgrd <- subset(somdataT, pt5>350, select = c(pt5,pt8))

No comments:

Post a Comment