Showing posts with label morphology. Show all posts
Showing posts with label morphology. Show all posts

Tuesday, July 1, 2014

Expression stddev ~ scmd stddev

expression stddev ~ scmd stddev, July 1, 2014
Expression stddev ~ scmd stddev give skewed to the left p-value distribution, excellent for false-discovery correction.

For the 49 GSE datasets that we analyzed, 44 of them give p<0.05 gseStddeve ~ scmdStddev. What does this mean? 


#RLS and these measures are not as significant as this correlations,
# but I have not tried G and m0.


# batch GSE stddev ~ scmdStddev, CV, 2014 July 1

setwd("~/github/ScottSummer14/Scott,sandbox14")
rm(list=ls())

#Read cellular morpholy mutant table with stddev, mean, CV into R
# scmd_CVbyRow20140701.csv was an output of "ScottSummer14/scmd_CV_20140701.R"
scmd = read.csv( "scmd_CVbyRow20140701.csv")
names(scmd)[c(1:2, 500:506)]
scmd$ORF = as.character(scmd$name)


#GSE files 
files = list.files(, path="data/GSElog2CV", pattern='GSE') 

output = data.frame(files)

# i = 1
for ( i in 1:length(files) ) {
  filename = paste( "data/GSElog2CV/", files[i], sep='')
  CV.tb = read.csv(filename)  
  CV.tb$ORF = as.character( CV.tb$ORF )

  tb = merge(CV.tb, scmd[, c(1:2,502:506)] )#based on ORF
  
  m = lm(tb$myCV ~ tb$CV)  
  s = summary(m)
  output$p.gseCV.scmdCV[i] = 1-pf( s$fstat[1], s$fstat[2], s$fstat[3])
  
  m = lm(tb$myStddev ~ tb$stddev)  
  s = summary(m)
  output$p.gseStddev.scmdStddev[i] = 1-pf( s$fstat[1], s$fstat[2], s$fstat[3])
  
}

summary(output)
hist(output$p.gseStddev.scmdStddev, br=20)

SCMD_CV_20140701.R

"ScottSummer14/scmd_CV_20140701.R"


#######################
#Now, let's look at morphological robustness

#Read cellular morpholy mutant table into R
scmd = read.table( "data/scmd.tab", sep="\t", header=T)

#Normalize the data by column. This took <1min in my apple laptop "byte"
row.names(scmd) = as.character( scmd$name )
for( j in 2:502 ){
  scmd[,j] = ( scmd[,j] - mean(scmd[,j],na.rm=T) )/ sqrt( var( scmd[,j], na.rm=T))
};
head(scmd)


#Calculate sigma, standard deviation, CV by row. This took about 10 min in apple laptop. 
for ( i in 1:4718){
  scmd$stddev[i] = sqrt(var( t(scmd[i,2:502]), na.rm=T ) )
  scmd$mean[i] = mean( t(scmd[i,2:502]), na.rm=T ) 
}; 
scmd$CV = scmd$stddev / (scmd$mean - min(scmd$mean) + 0.01) #make sure CV is positive ##20140701, this is probably a bug and lead some volatile calculations. 

head(scmd[,c("CV", "stddev", "mean")])
summary(scmd[,c("CV", "stddev", "mean")])

names(scmd)[c(1:3, 500:505)]; #check the column names

write.csv(scmd, "scmd_CVbyRow20140701.csv", quote=F, row.names=F)