This commit is contained in:
2024-08-13 15:27:53 -04:00
parent 724b292dab
commit f190967383
7 changed files with 367 additions and 298 deletions

View File

@@ -20,25 +20,25 @@ library(htmlwidgets)
# Parse arguments
args <- commandArgs(TRUE)
inputFile <- args[1]
inputFile <- file.path(args[1])
# Set output dir
if (length(args) >= 2) {
outDir <- args[2]
outDir <- file.path(args[2])
} else {
outDir <- "/ZScores/" # for legacy workflow
}
# Set StudyInfo file path
if (length(args) >= 3) {
studyInfo <- args[3]
studyInfo <- file.path(args[3])
} else {
studyInfo <- "../Code/StudyInfo.csv" # for legacy workflow
}
# Set SGDgeneList file path
if (length(args) >= 4) {
SGDgeneList <- args[4]
SGDgeneList <- file.path(args[4])
} else {
SGDgeneList <- "../Code/SGD_features.tab" # for legacy workflow
}
@@ -54,7 +54,7 @@ if (length(args) >= 5) {
}
delBGFactor <- as.numeric(delBGFactor)
if (is.na(delBGFactor)) {
delBGFactor <- 3 # Recommended by Sean
delBGFactor <- 3 # recommended by Sean
}
print(paste("The Standard Deviation Value is:", delBGFactor))
@@ -68,21 +68,25 @@ if (length(args) >= 6) {
}
expNumber <- as.numeric(expNumber)
outDir_QC <- paste(outDir, "QC/", sep = "")
outDir_QC <- file.path(outDir, "QC")
if (!file.exists(outDir)) {
dir.create(file.path(outDir))
dir.create(outDir)
}
if (!file.exists(outDir_QC)) {
dir.create(file.path(outDir_QC))
}
# 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 = studyInfo, stringsAsFactors = FALSE) # sep = ","
Labels[expNumber, 3] <- delBGFactor
write.csv(Labels, file = studyInfo, row.names = FALSE)
options(width = 1000)
ls.str()
# Write delBJFactor to the StudyInfo file
# TODO we probably shouldn't be doing this, need one source of truth
# TODO disabling this for now
# Labels <- read.csv(file = studyInfo, stringsAsFactors = FALSE) # sep = ","
# Labels[expNumber, 3] <- delBGFactor
# write.csv(Labels, file = studyInfo, row.names = FALSE)
# Begin User Data Selection Section
@@ -366,19 +370,19 @@ Raw_l_vs_K_beforeQC <-
ggtitle("Raw L vs K before QC") +
theme_publication_legend_right()
pdf(paste(outDir_QC, "Raw_L_vs_K_beforeQC.pdf", sep = ""), width = 12, height = 8)
pdf(file.path(outDir_QC, "Raw_L_vs_K_beforeQC.pdf"), width = 12, height = 8)
Raw_l_vs_K_beforeQC
dev.off()
pgg <- ggplotly(Raw_l_vs_K_beforeQC)
plotly_path <- paste(outDir_QC, "Raw_L_vs_K_beforeQC.html", sep = "")
plotly_path <- file.path(outDir_QC, "Raw_L_vs_K_beforeQC.html")
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) + (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 = " "))
sprintf("Delta_Background_Tolerance is %f", Delta_Background_Tolerance)
Plate_Analysis_Delta_Backgrd <-
ggplot(X, aes(Scan, Delta_Backgrd, color = as.factor(Conc_Num))) +
@@ -417,13 +421,13 @@ X_Delta_Backgrd_above_Tolerance_L_vs_K <-
) +
theme_publication_legend_right()
pdf(paste(outDir_QC, "Raw_L_vs_K_for_strains_above_deltabackgrd_threshold.pdf", sep = ""), width = 12, height = 8)
pdf(file.path(outDir_QC, "Raw_L_vs_K_for_strains_above_deltabackgrd_threshold.pdf"), width = 12, height = 8)
X_Delta_Backgrd_above_Tolerance_L_vs_K
dev.off()
pgg <- ggplotly(X_Delta_Backgrd_above_Tolerance_L_vs_K)
plotly_path <- paste(outDir_QC, "Raw_L_vs_K_for_strains_above_deltabackgrd_threshold.html", sep = "")
plotly_path <- file.path(outDir_QC, "Raw_L_vs_K_for_strains_above_deltabackgrd_threshold.html")
saveWidget(pgg, file = plotly_path, selfcontained = TRUE)
# Frequency plot for all data vs. the delta_background
@@ -434,7 +438,7 @@ DeltaBackground_Frequency_Plot <- ggplot(X, aes(Delta_Backgrd, color = as.factor
DeltaBackground_Bar_Plot <- ggplot(X, aes(Delta_Backgrd, color = as.factor(Conc_Num))) + geom_bar() +
ggtitle("Bar plot for Delta Background by Conc All Data") + theme_publication_legend_right()
pdf(file = paste(outDir_QC, "Frequency_Delta_Background.pdf", sep = ""), width = 12, height = 8)
pdf(file.path(outDir_QC, "Frequency_Delta_Background.pdf"), width = 12, height = 8)
print(DeltaBackground_Frequency_Plot)
print(DeltaBackground_Bar_Plot)
dev.off()
@@ -568,7 +572,7 @@ Plate_Analysis_Delta_Backgrd_Box_afterQC <-
theme_publication()
# Print the plate analysis data before and after QC
pdf(file = paste(outDir_QC, "Plate_Analysis.pdf", sep = ""), width = 14, height = 9)
pdf(file.path(outDir_QC, "Plate_Analysis.pdf"), width = 14, height = 9)
Plate_Analysis_L
Plate_Analysis_L_afterQC
Plate_Analysis_K
@@ -582,7 +586,7 @@ Plate_Analysis_Delta_Backgrd_afterQC
dev.off()
# Print the plate analysis data before and after QC
pdf(file = paste(outDir_QC, "Plate_Analysis_Boxplots.pdf", sep = ""), width = 18, height = 9)
pdf(file.path(outDir_QC, "Plate_Analysis_Boxplots.pdf"), width = 18, height = 9)
Plate_Analysis_L_Box
Plate_Analysis_L_Box_afterQC
Plate_Analysis_K_Box
@@ -713,7 +717,7 @@ Plate_Analysis_Delta_Backgrd_Box_afterQC_Z <-
theme_publication()
# Print the plate analysis data before and after QC
pdf(file = paste(outDir_QC, "Plate_Analysis_noZeros.pdf", sep = ""), width = 14, height = 9)
pdf(file.path(outDir_QC, "Plate_Analysis_noZeros.pdf"), width = 14, height = 9)
Plate_Analysis_L_afterQC_Z
Plate_Analysis_K_afterQC_Z
Plate_Analysis_r_afterQC_Z
@@ -722,7 +726,7 @@ Plate_Analysis_Delta_Backgrd_afterQC_Z
dev.off()
# Print the plate analysis data before and after QC
pdf(file = paste(outDir_QC, "Plate_Analysis_noZeros_Boxplots.pdf", sep = ""), width = 18, height = 9)
pdf(file.path(outDir_QC, "Plate_Analysis_noZeros_Boxplots.pdf"), width = 18, height = 9)
Plate_Analysis_L_Box_afterQC_Z
Plate_Analysis_K_Box_afterQC_Z
Plate_Analysis_r_Box_afterQC_Z
@@ -768,7 +772,7 @@ X_stats_ALL <- ddply(
)
# print(X_stats_ALL_L)
write.csv(X_stats_ALL, file = paste(outDir, "SummaryStats_ALLSTRAINS.csv"), row.names = FALSE)
write.csv(X_stats_ALL, file.path(outDir, "SummaryStats_ALLSTRAINS.csv"), row.names = FALSE)
# Part 3 - Generate summary statistics and calculate the max theoretical L value
# Calculate the Z score at each drug conc for each deletion strain
@@ -885,7 +889,7 @@ for (s in Background_Strains) {
se_AUC = sd_AUC / sqrt(N - 1)
)
write.csv(X_stats_BY, file = paste(outDir, "SummaryStats_BackgroundStrains.csv"), row.names = FALSE)
write.csv(X_stats_BY, file.path(outDir, "SummaryStats_BackgroundStrains.csv"), row.names = FALSE)
# Calculate the max theoretical L values
# Only look for max values when K is within 2SD of the ref strain
@@ -964,7 +968,7 @@ for (s in Background_Strains) {
write.csv(
X_stats_BY_L_within_2SD_K,
file = paste(outDir_QC, "Max_Observed_L_Vals_for_spots_within_2SD_K.csv", sep = ""),
file.path(outDir_QC, "Max_Observed_L_Vals_for_spots_within_2SD_K.csv"),
row.names = FALSE
)
@@ -991,13 +995,13 @@ for (s in Background_Strains) {
ggtitle("Raw L vs K for strains falling outside 2SD of the K mean at each conc") +
theme_publication_legend_right()
pdf(paste(outDir_QC, "Raw_L_vs_K_for_strains_2SD_outside_mean_K.pdf", sep = ""), width = 10, height = 8)
pdf(file.path(outDir_QC, "Raw_L_vs_K_for_strains_2SD_outside_mean_K.pdf"), width = 10, height = 8)
print(Outside_2SD_K_L_vs_K)
dev.off()
pgg <- ggplotly(Outside_2SD_K_L_vs_K)
plotly_path <- paste(outDir_QC, "RawL_vs_K_for_strains_outside_2SD_K.html", sep = "")
plotly_path <- file.path(outDir_QC, "RawL_vs_K_for_strains_outside_2SD_K.html")
saveWidget(pgg, file = plotly_path, selfcontained = TRUE)
Outside_2SD_K_delta_background_vs_K <-
@@ -1006,13 +1010,13 @@ for (s in Background_Strains) {
ggtitle("DeltaBackground vs K for strains falling outside 2SD of the K mean at each conc") +
theme_publication_legend_right()
pdf(paste(outDir_QC, "DeltaBackground_vs_K_for_strains_2SD_outside_mean_K.pdf", sep = ""), width = 10, height = 8)
pdf(file.path(outDir_QC, "DeltaBackground_vs_K_for_strains_2SD_outside_mean_K.pdf"), width = 10, height = 8)
Outside_2SD_K_delta_background_vs_K
dev.off()
pgg <- ggplotly(Outside_2SD_K_delta_background_vs_K)
# pgg
plotly_path <- paste(outDir_QC, "DeltaBackground_vs_K_for_strains_outside_2SD_K.html", sep = "")
plotly_path <- file.path(outDir_QC, "DeltaBackground_vs_K_for_strains_outside_2SD_K.html")
saveWidget(pgg, file = plotly_path, selfcontained = TRUE)
# Get the background strain mean values at the no drug conc to calculate shift
@@ -1046,7 +1050,7 @@ for (s in Background_Strains) {
X2_temp <- X2[X2$Conc_Num == Concentration, ]
if (Concentration == 0) {
X2_new <- X2_temp
print(paste("Check loop order, conc =", Concentration, sep = " "))
sprintf("Check loop order, conc = %f", Concentration)
}
if (Concentration > 0) {
try(X2_temp[X2_temp$l == 0 & !is.na(X2_temp$l), ]$l <- X_stats_BY_L_within_2SD_K$max[i])
@@ -1055,7 +1059,7 @@ for (s in Background_Strains) {
# X2_temp[X2_temp$K == 0, ]$K <- X_stats_ALL_K$max[i]
# X2_temp[X2_temp$r == 0, ]$r <- X_stats_ALL_r$max[i]
# X2_temp[X2_temp$AUC == 0, ]$AUC <- X_stats_ALL_AUC$max[i]
print(paste("Check loop order, conc =", Concentration, sep = " "))
sprintf("Check loop order, conc = %f", Concentration)
X2_new <- rbind(X2_new, X2_temp)
}
}
@@ -1075,13 +1079,13 @@ for (s in Background_Strains) {
X2_RF_temp <- X2_RF[X2_RF$Conc_Num == Concentration, ]
if (Concentration == 0) {
X2_RF_new <- X2_RF_temp
print(paste("Check loop order, conc =", Concentration, sep = " "))
sprintf("Check loop order, conc = %f", Concentration)
}
if (Concentration > 0) {
try(X2_RF_temp[X2_RF_temp$l == 0 & !is.na(X2_RF_temp$l), ]$l <- X_stats_BY_L_within_2SD_K$max[i])
try(X2_temp[X2_temp$l >= X_stats_BY_L_within_2SD_K$max[i] & !is.na(X2_temp$l), ]$SM <- 1)
try(X2_RF_temp[X2_RF_temp$l >= X_stats_BY_L_within_2SD_K$max[i] & !is.na(X2_RF_temp$l), ]$l <- X_stats_BY_L_within_2SD_K$max[i])
print(paste("If error, refs have no L values outside theoretical max L, for REFs, conc =", Concentration, sep = " "))
sprintf("If error, refs have no L values outside theoretical max L, for REFs, conc = %f", Concentration)
X2_RF_new <- rbind(X2_RF_new, X2_RF_temp)
}
}
@@ -1446,7 +1450,7 @@ for (s in Background_Strains) {
InteractionScores_RF$Z_lm_AUC <- (InteractionScores_RF$lm_Score_AUC - lm_mean_AUC) / (lm_sd_AUC)
InteractionScores_RF <- InteractionScores_RF[order(InteractionScores_RF$Z_lm_L, decreasing = TRUE), ]
InteractionScores_RF <- InteractionScores_RF[order(InteractionScores_RF$NG, decreasing = TRUE), ]
write.csv(InteractionScores_RF, paste(outDir, "RF_ZScores_Interaction.csv", sep = ""), row.names = FALSE)
write.csv(InteractionScores_RF, file.path(outDir, "RF_ZScores_Interaction.csv"), row.names = FALSE)
for (i in 1:num_genes_RF) {
Gene_Sel <- unique(InteractionScores_RF$OrfRep)[i]
@@ -1548,7 +1552,7 @@ for (s in Background_Strains) {
}
}
print("Pass RF ggplot loop")
write.csv(X_stats_interaction_ALL_RF_final, paste(outDir, "RF_ZScore_Calculations.csv", sep = ""), row.names = FALSE)
write.csv(X_stats_interaction_ALL_RF_final, file.path(outDir, "RF_ZScore_Calculations.csv"), row.names = FALSE)
# Part 5 - Get Zscores for Gene deletion strains
@@ -1904,7 +1908,7 @@ for (s in Background_Strains) {
InteractionScores <- InteractionScores[order(InteractionScores$NG, decreasing = TRUE), ]
df_order_by_OrfRep <- unique(InteractionScores$OrfRep)
# X_stats_interaction_ALL <- X_stats_interaction_ALL[order(X_stats_interaction_ALL$NG, decreasing = TRUE), ]
write.csv(InteractionScores, paste(outDir, "ZScores_Interaction.csv", sep = ""), row.names = FALSE)
write.csv(InteractionScores, file.path(outDir, "ZScores_Interaction.csv"), row.names = FALSE)
InteractionScores_deletion_enhancers_L <-
InteractionScores[InteractionScores$Avg_Zscore_L >= 2, ]
@@ -1957,25 +1961,25 @@ for (s in Background_Strains) {
InteractionScores_deletion_enhancers_Avg_Zscore_Suppressors_lm_K[
!is.na(InteractionScores_deletion_enhancers_Avg_Zscore_Suppressors_lm_K$OrfRep), ]
write.csv(InteractionScores_deletion_enhancers_L,
paste(outDir, "ZScores_Interaction_DeletionEnhancers_L.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_DeletionEnhancers_L.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_enhancers_K,
paste(outDir, "ZScores_Interaction_DeletionEnhancers_K.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_DeletionEnhancers_K.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_suppressors_L,
paste(outDir, "ZScores_Interaction_DeletionSuppressors_L.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_DeletionSuppressors_L.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_suppressors_K,
paste(outDir, "ZScores_Interaction_DeletionSuppressors_K.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_DeletionSuppressors_K.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_enhancers_and_Suppressors_L,
paste(outDir, "ZScores_Interaction_DeletionEnhancers_and_Suppressors_L.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_DeletionEnhancers_and_Suppressors_L.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_enhancers_and_Suppressors_K,
paste(outDir, "ZScores_Interaction_DeletionEnhancers_and_Suppressors_K.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_DeletionEnhancers_and_Suppressors_K.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_enhancers_lm_Suppressors_AvgZscore_L,
paste(outDir, "ZScores_Interaction_Suppressors_and_lm_Enhancers_L.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_Suppressors_and_lm_Enhancers_L.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_enhancers_Avg_Zscore_Suppressors_lm_L,
paste(outDir, "ZScores_Interaction_Enhancers_and_lm_Suppressors_L.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_Enhancers_and_lm_Suppressors_L.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_enhancers_lm_Suppressors_AvgZscore_K,
paste(outDir, "ZScores_Interaction_Suppressors_and_lm_Enhancers_K.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_Suppressors_and_lm_Enhancers_K.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_enhancers_Avg_Zscore_Suppressors_lm_K,
paste(outDir, "ZScores_Interaction_Enhancers_and_lm_Suppressors_K.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_Enhancers_and_lm_Suppressors_K.csv"), row.names = FALSE)
# Get enhancers and suppressors for linear regression
InteractionScores_deletion_enhancers_L_lm <-
@@ -2010,19 +2014,19 @@ for (s in Background_Strains) {
!is.na(InteractionScores_deletion_enhancers_and_Suppressors_K_lm$OrfRep), ]
write.csv(InteractionScores_deletion_enhancers_L_lm,
paste(outDir, "ZScores_Interaction_DeletionEnhancers_L_lm.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_DeletionEnhancers_L_lm.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_enhancers_K_lm,
paste(outDir, "ZScores_Interaction_DeletionEnhancers_K_lm.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_DeletionEnhancers_K_lm.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_suppressors_L_lm,
paste(outDir, "ZScores_Interaction_DeletionSuppressors_L_lm.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_DeletionSuppressors_L_lm.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_suppressors_K_lm,
paste(outDir, "ZScores_Interaction_DeletionSuppressors_K_lm.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_DeletionSuppressors_K_lm.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_enhancers_and_Suppressors_L_lm,
paste(outDir, "ZScores_Interaction_DeletionEnhancers_and_Suppressors_L_lm.csv", sep = ""), row.names = FALSE)
file.path(outDir, "ZScores_Interaction_DeletionEnhancers_and_Suppressors_L_lm.csv"), row.names = FALSE)
write.csv(InteractionScores_deletion_enhancers_and_Suppressors_K_lm,
paste(outDir, "ZScores_Interaction_DeletionEnhancers_and_Suppressors_K_lm.csv", sep = ""), row.names = FALSE)
write.csv(Labels, file = paste(studyInfo), row.names = FALSE)
# write.table(Labels, file = paste("../Code/StudyInfo.txt"), sep = "\t", row.names = FALSE)
file.path(outDir, "ZScores_Interaction_DeletionEnhancers_and_Suppressors_K_lm.csv"), row.names = FALSE)
# write.csv(Labels, studyInfo, row.names = FALSE)
# write.table(Labels, file.path("../Code/StudyInfo.txt"), sep = "\t", row.names = FALSE)
for (i in 1:num_genes) {
Gene_Sel <- unique(InteractionScores$OrfRep)[i]
@@ -2113,11 +2117,11 @@ for (s in Background_Strains) {
}
}
print("Pass Int ggplot loop")
write.csv(X_stats_interaction_ALL_final, paste(outDir, "ZScore_Calculations.csv", sep = ""), row.names = FALSE)
write.csv(X_stats_interaction_ALL_final, file.path(outDir, "ZScore_Calculations.csv"), row.names = FALSE)
Blank <- ggplot(X2_RF) + geom_blank()
pdf(paste(outDir, "InteractionPlots.pdf", sep = ""), width = 16, height = 16, onefile = TRUE)
pdf(file.path(outDir, "InteractionPlots.pdf"), width = 16, height = 16, onefile = TRUE)
X_stats_X2_RF <- ddply(
X2_RF,
@@ -2344,7 +2348,7 @@ for (s in Background_Strains) {
dev.off()
pdf(paste(outDir, "RF_InteractionPlots.pdf", sep = ""), width = 16, height = 16, onefile = TRUE)
pdf(file.path(outDir, "RF_InteractionPlots.pdf"), width = 16, height = 16, onefile = TRUE)
X_stats_X2_RF <- ddply(
X2_RF,
@@ -2732,7 +2736,7 @@ for (s in Background_Strains) {
geom_hline(yintercept = c(-3, 3)) + geom_point(size = 0.1, shape = 3) +
theme_publication()
pdf(paste(outDir, "RankPlots.pdf", sep = ""), width = 18, height = 12, onefile = TRUE)
pdf(file.path(outDir, "RankPlots.pdf"), width = 18, height = 12, onefile = TRUE)
grid.arrange(
Rank_L_1SD,
@@ -2866,7 +2870,7 @@ for (s in Background_Strains) {
geom_hline(yintercept = c(-3, 3)) + geom_point(size = 0.1, shape = 3) +
theme_publication()
pdf(paste(outDir, "RankPlots_lm.pdf", sep = ""), width = 18, height = 12, onefile = TRUE)
pdf(file.path(outDir, "RankPlots_lm.pdf"), width = 18, height = 12, onefile = TRUE)
grid.arrange(
Rank_L_1SD_lm,
@@ -2916,7 +2920,7 @@ for (s in Background_Strains) {
get_lm_AUC <- lm(X_NArm$Z_lm_AUC ~ X_NArm$Avg_Zscore_AUC)
AUC_lm <- summary(get_lm_AUC)
pdf(paste(outDir, "Avg_Zscore_vs_lm_NA_rm.pdf", sep = ""), width = 16, height = 12, onefile = TRUE)
pdf(file.path(outDir, "Avg_Zscore_vs_lm_NA_rm.pdf"), width = 16, height = 12, onefile = TRUE)
print(ggplot(X_NArm, aes(Avg_Zscore_L, Z_lm_L)) +
geom_point(aes(color = Overlap), shape = 3) +
@@ -2955,7 +2959,7 @@ for (s in Background_Strains) {
annotate("text", x = 0, y = 0, label = paste("R-squared = ", round(L_lm$r.squared, 2))) + theme_publication_legend_right()
pgg <- ggplotly(lm_v_Zscore_L)
plotly_path <- paste(outDir, "Avg_Zscore_vs_lm_NA_rm.html", sep = "")
plotly_path <- file.path(outDir, "Avg_Zscore_vs_lm_NA_rm.html")
saveWidget(pgg, file = plotly_path, selfcontained = TRUE)
X_NArm$L_Rank <- rank(X_NArm$Avg_Zscore_L)
@@ -2978,7 +2982,7 @@ for (s in Background_Strains) {
AUC_lm2 <- summary(get_lm_AUC2)
num_genes_NArm2 <- (dim(X_NArm)[1]) / 2
pdf(paste(outDir, "Avg_Zscore_vs_lm_ranked_NA_rm.pdf", sep = ""), width = 16, height = 12, onefile = TRUE)
pdf(file.path(outDir, "Avg_Zscore_vs_lm_ranked_NA_rm.pdf"), width = 16, height = 12, onefile = TRUE)
print(
ggplot(X_NArm, aes(L_Rank, L_Rank_lm)) +
@@ -3114,7 +3118,7 @@ for (s in Background_Strains) {
geom_hline(yintercept = c(-3, 3)) + geom_point(size = 0.1, shape = 3) +
theme_publication()
pdf(paste(outDir, "RankPlots_naRM.pdf", sep = ""), width = 18, height = 12, onefile = TRUE)
pdf(file.path(outDir, "RankPlots_naRM.pdf"), width = 18, height = 12, onefile = TRUE)
grid.arrange(
Rank_L_1SD,
@@ -3234,7 +3238,7 @@ for (s in Background_Strains) {
geom_hline(yintercept = c(-3, 3)) + geom_point(size = 0.1, shape = 3) +
theme_publication()
pdf(paste(outDir, "RankPlots_lm_naRM.pdf", sep = ""), width = 18, height = 12, onefile = TRUE)
pdf(file.path(outDir, "RankPlots_lm_naRM.pdf"), width = 18, height = 12, onefile = TRUE)
grid.arrange(
Rank_L_1SD_lm,
@@ -3273,7 +3277,7 @@ L_lm_5 <- summary(get_lm_5)
get_lm_6 <- lm(X_NArm$Z_lm_AUC ~ X_NArm$Z_lm_r)
L_lm_6 <- summary(get_lm_6)
pdf(file = paste(outDir, "Correlation_CPPs.pdf", sep = ""), width = 10, height = 7, onefile = TRUE)
pdf(file.path(outDir, "Correlation_CPPs.pdf"), width = 10, height = 7, onefile = TRUE)
ggplot(X_NArm, aes(Z_lm_L, Z_lm_K)) +
geom_point(shape = 3, color = "gray70") +
@@ -3482,5 +3486,5 @@ ggplot(X_NArm, aes(Z_lm_r, Z_lm_AUC)) +
dev.off()
# write.csv(Labels, file = paste("../Code/Parameters.csv"), row.names = FALSE)
# write.csv(Labels, file.path("../Code/Parameters.csv"), row.names = FALSE)
timestamp()