Finish PairwiseLK module

This commit is contained in:
2024-07-24 21:11:25 -04:00
parent 7b8ce3e7fd
commit ef449c66ff
6 changed files with 594 additions and 481 deletions

View File

@@ -1,41 +1,67 @@
#4.This R script performs GTA L and K Pairwise Compares for user specified pairs of Experiments
#Arg1 is the first Experiment or a user ordered pair (i.e., Exp3)
#Arg2 is the second Experiment or a user ordered pair (i.e., Exp4)
#Note user can put whatever names they wish for the Canonical Exp1..4 in the ../Code/ExpLabels.txt spread sheet
#which correlates the canonical Exp Name with the user stylized label for plots and output files.
#!/usr/bin/env Rscript
# This R script performs GTA L and K Pairwise Compares for user specified pairs of Experiments
#
# Updated 240724 Bryan C Roessler to improve file operations and portability
# NOTE: The two required arguments are the same and now there are two optional arguments
# 1. Exp1
# 2. Exp2
# 3. StudyInfo.csv file
# 4. Output Directory
library("ggplot2")
library("plotly")
library("htmlwidgets")
library("extrafont")
library("grid")
library("ggthemes")
library(ggplot2)
library(plotly)
library(htmlwidgets)
library(extrafont)
library(grid)
library(ggthemes)
Args <- commandArgs(TRUE)
args <- commandArgs(TRUE)
exp_name <- args[1]
exp_name2 <- args[2]
expNm= Args[1] #i.e., "Exp3"
expNm[2]= Args[2] #i.e., "Exp4"
expNumber1<- as.numeric(sub("^.*?(\\d+)$", "\\1", expNm[1]))
expNumber2<- as.numeric(sub("^.*?(\\d+)$", "\\1", expNm[2]))
#labels <- read.delim("ExpLabels.txt",skip=0,as.is=T,row.names=1,strip.white=TRUE)
#labels <- read.delim("StudyInfo.csv",skip=0,as.is=T,row.names=1,strip.white=TRUE)
Labels<- read.csv(file= "StudyInfo.csv",stringsAsFactors = FALSE)
Name1 <- Labels[expNumber1,2] #ssArg2 These are now supplied by Code/ExpLabels.csv which is user edited
Name2 <- Labels[expNumber2,2] #ssArg4
Wstudy= getwd()
input_file1 <- paste0("../GTAresults/",expNm[1],"/Average_GOTerms_All.csv" ) #Args[1]
input_file2 <- paste0("../GTAresults/",expNm[2],"/Average_GOTerms_All.csv" ) #Args[3]
if (length(args) > 3) {
study_info_file <- args[3]
} else {
study_info_file <- "StudyInfo.csv"
}
pairDirL= paste0("../GTAresults/","PairwiseCompareL_",expNm[1],"-",expNm[2])
pairDirK= paste0("../GTAresults/","PairwiseCompareK_",expNm[1],"-",expNm[2])
outPathGTAcompare= "../GTAresults/PairwiseCompareL" #paste0(Wstudy,"/GTAresults/PairwiseCompareL)
outPathGTAcompare[2]= "../GTAresults/PairwiseCompareK" #paste0(Wstudy,"/GTAresults/PairwiseCompareK")
if (length(args) > 4) {
output_dir <- args[4]
} else {
output_dir <- "../GTAresults"
}
# if (length(args) > 3) {
# sgd_terms_file <- args[3]
# } else {
# sgd_terms_file <- "../Code/go_terms.tab"
# }
# if (length(args) > 4) {
# sgd_features_file <- args[4]
# } else {
# sgd_features_file <- "../Code/gene_association.sgd"
# }
expNumber1<- as.numeric(sub("^.*?(\\d+)$", "\\1", exp_name))
expNumber2<- as.numeric(sub("^.*?(\\d+)$", "\\1", exp_name2))
Labels<- read.csv(file=study_info_file,stringsAsFactors = FALSE)
Name1 <- Labels[expNumber1,2]
Name2 <- Labels[expNumber2,2]
go_terms_file <- "Average_GOTerms_All.csv"
input_file1 <- file.path(output_dir,exp_name,go_terms_file)
input_file2 <- file.path(output_dir,exp_name2,go_terms_file)
pairDirL= file.path(output_dir,"PairwiseCompareL_",exp_name,"-",exp_name2)
pairDirK= file.path(output_dir,"PairwiseCompareK_",exp_name,"-",exp_name2)
outPathGTAcompare= file.path(output_dir,"PairwiseCompareL")
outPathGTAcompare[2]= file.path(output_dir,"PairwiseCompareK")
#dir.create(outPathGTAcompare[1])
dir.create(pairDirL) #(outPathGTAcompare[1])
dir.create(pairDirK) #(outPathGTAcompare[2])
###########BEGIN PAIRWISE L-----LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
#define the output path (as fourth argument from Rscript)
outputpath <- pairDirL #outPathGTAcompare[1] #Args[5]
#outputPlotly <- "../GTAresults/PairwiseCompareL/" #"/GTAresults/PairwiseCompareL/"
print("39")