Skip to content

Instantly share code, notes, and snippets.

@CnrLwlss
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CnrLwlss/b6f79cfa697bab12bc01 to your computer and use it in GitHub Desktop.
Save CnrLwlss/b6f79cfa697bab12bc01 to your computer and use it in GitHub Desktop.
# To execute this script manually, in parallel on multiple CPUs:
# Rscript Scripts/QFA_ANALYSIS_INDIVIDUAL.R QFA0028 QFA0029 &
# Rscript Scripts/QFA_ANALYSIS_INDIVIDUAL.R QFA0030 QFA0031 &
library(parallel)
source("Scripts/QFA_ANALYSIS.R")
PLOSGenetics=sprintf("QFA%04d",c(28,29,30,31,35,36))
# NCPUs is the maximum number of CPUs the script can use on this node (should be less than 48 on cisban cluster)
NCPUs=47
cisbanNodes=TRUE
# Optionally spcify files for analysis here
#flist=c("QFA0135")
#flist=sprintf("QFA%04d",1:16)
#flist=sprintf("QFA%04d",c(28,29,30,31,35,36))
flist=sprintf("QFA%04d",c(6,10,11,12,18)) # Marion's expts
# Try lots of different AUClim
QFA_nAUCdef=function() {
times=seq(0.2,5.0,0.2)
return(function(cfolder,modelFit) QFA_analysis(cfolder=cfolder,modelFit=modelFit,AUClim=times))
}
QFA_nAUC=QFA_nAUCdef()
# If any experiments specified in command line, use those instead of flist specified above
args <- commandArgs(trailingOnly = TRUE)
if(length(args)>0){
flist=args
}
# Discard experiments without the relevant directories
flist=flist[file.exists(file.path("QFA_EXPERIMENTS",flist))]
Nlist=length(flist)
if(length(args)>0){
#for(f in flist) QFA_analysis(f)
for(f in flist) QFA_nAUC(cfolder=f,modelFit=TRUE)
}else{
# Read image logs and carry out model fitting
if(cisbanNodes){
actCPUs=min(Nlist,NCPUs) # detectCores() to find number of CPUs on local machine...
nodes=c("cisban-node3","cisban-node2","cisban-node1")
nodes=sort(rep(nodes,16),decreasing=TRUE)
}else{
actCPUs=min(detectCores()-1,Nlist,NCPUs)
nodes=rep("localhost",actCPUs)
}
print(paste("Attempting to analyse files:",flist))
cl <- makePSOCKcluster(nodes[1:actCPUs])
clusterEvalQ(cl,library(qfa))
if(cisbanNodes) clusterEvalQ(cl,setwd("/home/yeastimages/LOGS3"))
clusterEvalQ(cl,source("Scripts/QFA_ANALYSIS.R"))
#clusterApply(cl,flist,QFA_analysis,AUClim=AUCs,glog=TRUE,elab=elabs,modelFit=FALSE)
clusterApply(cl,flist,QFA_nAUC,modelFit=TRUE)
stopCluster(cl)
makeImBrowser=function(barcode,imtime=2.0,skipDone=TRUE){
string=paste("python /home/yeastimages/LOGS3/Scripts/makeHTML_HTS.py",barcode,imtime)
print(string)
if(!skipDone|length(dir(file.path("QFA_EXPERIMENTS",barcode,"IMAGEBROWSER")) ==0)){
system(string)
}else{
print(paste("Skipping image browser for",barcode,", already generated"))
}
}
# Clear image file location database, ready to be re-built with latest images
if(file.exists("barcb.json")) file.remove("barcdb.json")
for(f in flist){
print(paste("Making image browsers for",f))
#makeImBrowser(f,2.0);
#makeImBrowser(f,0.75);
}
}
# Merge data from PLOS Genetics screens if any of them have been re-analysed
# Note that this will only happen if the PLOS Genetics experiments are NOT listed as exceptions
if(length(intersect(PLOSGenetics,flist))>0){
print("Binding PLOS Genetics experiments...")
source("QFA_EXPERIMENTS/QFA0139/SCRIPTS/QFA0139_Rbind.R")
source("QFA_EXPERIMENTS/QFA0140/SCRIPTS/QFA0140_rbind.R")
source("QFA_EXPERIMENTS/QFA0141/SCRIPTS/QFA0141_rbind.R")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment