Modularize joinInteractExps.R
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#Based on InteractionTemplate.R which is based on Sean Santose's Interaction_V5 script.
|
||||
#Adapt SS For Structured Data storage but using command line scripts
|
||||
###Set up the required libraries, call required plot theme elements and set up the command line arguments
|
||||
# Based on InteractionTemplate.R which is based on Sean Santose's Interaction_V5 script.
|
||||
# Adapt SS For Structured Data storage but using command line scripts
|
||||
# Set up the required libraries, call required plot theme elements and set up the command line arguments
|
||||
library("ggplot2")
|
||||
library("plyr")
|
||||
library("extrafont")
|
||||
@@ -8,24 +8,13 @@ library("gridExtra")
|
||||
library("gplots")
|
||||
library("RColorBrewer")
|
||||
library("stringr")
|
||||
#library("gdata")
|
||||
library(plotly)
|
||||
library(htmlwidgets)
|
||||
library("plotly")
|
||||
library("htmlwidgets")
|
||||
|
||||
Args <- commandArgs(TRUE)
|
||||
input_file <- Args[1] #"!!Results_17_0827_yor1null-rpl12anull misLabeledAsFrom MI 17_0919_yor1-curated.txt" #Args[1] #Arg 1 #"!!ResultsStd_JS 19_1224_HLEG_P53.txt" is the !!results ... .txt
|
||||
#Tool to find a file and copy it to desired location
|
||||
destDir= getwd()
|
||||
#srcFile= file.choose()
|
||||
#file.copy(srcFile, destDir)
|
||||
#input_file= tail(strsplit(srcFile,"[/]")[[1]],1)
|
||||
|
||||
|
||||
|
||||
#Path to Output Directory
|
||||
#W=getwd() #R is F'd up, Can't use, Any legitamate platform could build out dirs from this
|
||||
outDir <- "ZScores/" #"Args[2] #paste0(W,"/ZScores/")
|
||||
subDir <- outDir #Args[2]
|
||||
args <- commandArgs(TRUE)
|
||||
input_file <- args[1] #"!!Results_17_0827_yor1null-rpl12anull misLabeledAsFrom MI 17_0919_yor1-curated.txt" #args[1] #Arg 1 #"!!ResultsStd_JS 19_1224_HLEG_P53.txt" is the !!results ... .txt
|
||||
outDir <- "ZScores/" #"args[2] #paste0(W,"/ZScores/")
|
||||
subDir <- outDir #args[2]
|
||||
|
||||
if (file.exists(subDir)){
|
||||
outputpath <- subDir
|
||||
@@ -40,12 +29,12 @@ if (file.exists(paste(subDir,"QC/",sep=""))){
|
||||
outputpath_QC <- paste(subDir,"QC/",sep="")
|
||||
}
|
||||
#define the output path (formerly the second argument from Rscript)
|
||||
outputpath <- outDir
|
||||
outputpath <- outDir
|
||||
|
||||
#Set Args[2] the Background contamination noise filter as a function of standard deviation
|
||||
#std= as.numeric(Args[2])
|
||||
#Set args[2] the Background contamination noise filter as a function of standard deviation
|
||||
#std= as.numeric(args[2])
|
||||
#Sean recommends 3 or 5 SD factor.
|
||||
#Capture Exp_ number,use it to Save Args[2]{std}to Labels field and then Write to Labels to studyInfo.txt for future reference
|
||||
#Capture Exp_ number,use it to Save args[2]{std}to Labels field and then Write to Labels to studyInfo.txt for future reference
|
||||
Labels <- read.csv(file= "../Code/StudyInfo.csv",stringsAsFactors = FALSE) #,sep= ",")
|
||||
print("Be sure to enter Background noise filter standard deviation i.e., 3 or 5 per Sean")
|
||||
|
||||
@@ -59,20 +48,17 @@ if(!is.na(inpNum)){
|
||||
std= inpNum
|
||||
}else{std= 3}
|
||||
|
||||
|
||||
expNumber<- as.numeric(sub("^.*?(\\d+)$", "\\1", getwd()))
|
||||
Labels[expNumber,3]= as.numeric(std)
|
||||
Delta_Background_sdFactor <- std
|
||||
DelBGFactr <- as.numeric(Delta_Background_sdFactor)
|
||||
delBGFactor <- as.numeric(Delta_Background_sdFactor)
|
||||
#Write Background SD value to studyInfo.txt file
|
||||
#write.csv(Labels,file=paste("../Code/StudyInfo.csv"),row.names = FALSE)
|
||||
write.csv(Labels,file=paste("../Code/StudyInfo.csv"),row.names = FALSE)
|
||||
print('ln 50 write StudyInfo.csv ')
|
||||
#write.table(Labels,file=paste(outputpath,"StudyInfo.txt"),sep = "\t",row.names = FALSE)
|
||||
|
||||
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
#++++++BEGIN USER DATA SELECTION SECTION+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
# Begin user data selection section
|
||||
#read in the data
|
||||
X <- read.delim(input_file,skip=2,as.is=T,row.names=1,strip.white=TRUE)
|
||||
X <- X[!(X[[1]]%in%c("","Scan")),]
|
||||
@@ -325,7 +311,7 @@ saveWidget(pgg, file=plotly_path, selfcontained =TRUE)
|
||||
|
||||
|
||||
#set delta background tolerance based on 3 sds from the mean delta background
|
||||
Delta_Background_Tolerance <- mean(X$Delta_Backgrd)+(DelBGFactr*sd(X$Delta_Backgrd))
|
||||
Delta_Background_Tolerance <- mean(X$Delta_Backgrd)+(delBGFactor*sd(X$Delta_Backgrd))
|
||||
#Delta_Background_Tolerance <- mean(X$Delta_Backgrd)+(3*sd(X$Delta_Backgrd))
|
||||
print(paste("Delta_Background_Tolerance is",Delta_Background_Tolerance,sep=" "))
|
||||
|
||||
@@ -2718,13 +2704,13 @@ timestamp()
|
||||
|
||||
#BoneYard***********************************************
|
||||
#I'm thinking this parameter needs to be save somewhere "permanent' for the record so outputs can be reproduced.
|
||||
#take this out of the Arguments. In Matlab I could for future in .mat file. Maybe I could save the SD Args[2] as part of the StudyInfo.txt.
|
||||
#take this out of the Arguments. In Matlab I could for future in .mat file. Maybe I could save the SD args[2] as part of the StudyInfo.txt.
|
||||
#Corruptable but better than nothing.
|
||||
#if(is.na(Args[2])){
|
||||
#if(is.na(args[2])){
|
||||
# std=3
|
||||
#}else {
|
||||
# std= Arg[2]
|
||||
#Delta_Background_sdFactor <- 2 #Args[3]
|
||||
#DelBGFactr <- as.numeric(Delta_Background_sdFactor)
|
||||
#Delta_Background_sdFactor <- 2 #args[3]
|
||||
#delBGFactor <- as.numeric(Delta_Background_sdFactor)
|
||||
#}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ std= as.numeric(Args[2])
|
||||
expNumber<- as.numeric(sub("^.*?(\\d+)$", "\\1", getwd()))
|
||||
Labels[expNumber,3]= as.numeric(std)
|
||||
Delta_Background_sdFactor <- std
|
||||
DelBGFactr <- as.numeric(Delta_Background_sdFactor)
|
||||
delBGFactor <- as.numeric(Delta_Background_sdFactor)
|
||||
#Write Background SD value to studyInfo.txt file
|
||||
#write.csv(Labels,file=paste("../Code/StudyInfo.csv"),row.names = FALSE)
|
||||
write.csv(Labels,file=paste("../Code/StudyInfo.csv"),row.names = FALSE)
|
||||
@@ -297,7 +297,7 @@ saveWidget(pgg, file=plotly_path, selfcontained =TRUE)
|
||||
|
||||
|
||||
#set delta background tolerance based on 3 sds from the mean delta background
|
||||
Delta_Background_Tolerance <- mean(X$Delta_Backgrd)+(DelBGFactr*sd(X$Delta_Backgrd))
|
||||
Delta_Background_Tolerance <- mean(X$Delta_Backgrd)+(delBGFactor*sd(X$Delta_Backgrd))
|
||||
#Delta_Background_Tolerance <- mean(X$Delta_Backgrd)+(3*sd(X$Delta_Backgrd))
|
||||
print(paste("Delta_Background_Tolerance is",Delta_Background_Tolerance,sep=" "))
|
||||
|
||||
@@ -2697,6 +2697,6 @@ timestamp()
|
||||
#}else {
|
||||
# std= Arg[2]
|
||||
#Delta_Background_sdFactor <- 2 #Args[3]
|
||||
#DelBGFactr <- as.numeric(Delta_Background_sdFactor)
|
||||
#delBGFactor <- as.numeric(Delta_Background_sdFactor)
|
||||
#}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user