Skip to content

Commit 1da7b0e

Browse files
Explicitly defined data type of new columns to prevent "expected logical" error
1 parent 0bc3c5a commit 1da7b0e

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

OLGenie_sliding_windows.R

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ PREPEND_TO_OUTPUT <- ''
6363

6464
# Produce some helpful warning messages
6565
if(! (NBOOTSTRAPS >= 1 && NBOOTSTRAPS <= 1000000)) {
66-
cat("### WARNING: NBOOTSTRAPS must be in the range [1,1000000]. Using: 1000.\n")
66+
cat("\n### WARNING: NBOOTSTRAPS must be in the range [1,1000000]. Using: 1000.\n")
6767
NBOOTSTRAPS <- 1000
6868
}
6969

7070
if(! (MIN_DEFINED_CODONS >= 2)) {
71-
cat("### WARNING: MIN_DEFINED_CODONS must be ≥2. Using: 6.\n")
71+
cat("\n### WARNING: MIN_DEFINED_CODONS must be ≥2. Using: 6.\n")
7272
MIN_DEFINED_CODONS <- 6
7373
}
7474

7575
if(! is.na(ARGV[8]) && ARGV[8] == "JC") {
7676
CORRECTION <- as.character(ARGV[8])
77-
} else {
78-
cat("### WARNING: unrecognized CORRECTION supplied. Using: \"NONE\".\n")
77+
} else if (is.na(ARGV[8]) || ARGV[8] != "NONE") {
78+
cat("\n### WARNING: unrecognized CORRECTION supplied. Using: \"NONE\".\n")
7979
}
8080

8181
if(! is.na(ARGV[9]) && str_detect(string = ARGV[9], pattern = "\\d") && ! str_detect(string = ARGV[9], pattern = "[a-zA-Z]")) {
@@ -87,7 +87,7 @@ if(! is.na(ARGV[10])) {
8787
}
8888

8989
# EXAMPLES
90-
#CODON_RESULTS_FILE <- "/Users/cwnelson88/Desktop/SCIENCE/Karlin_OLGs_B19/OLGenie_codon_results.txt"
90+
#CODON_RESULTS_FILE <- "/Users/chase/Desktop/OLG_projects/OLGenie-out.txt"
9191
#NUMERATOR <- "NN"
9292
#DENOMINATOR <- "NS"
9393
#WINDOW_SIZE <- 25
@@ -296,36 +296,36 @@ dNdS_diff_boot_fun_JC <- function(codon_results, numerator, denominator, num_rep
296296
### ADD COLUMNS TO DATA
297297
RATIO_NAME <- paste0('d', NUMERATOR, 'd', DENOMINATOR)
298298
codon_data$sw_ratio <- RATIO_NAME
299-
codon_data$sw_start <- NA
300-
codon_data$sw_center <- NA
301-
codon_data$sw_end <- NA
302-
codon_data$sw_num_replicates <- NA
303-
codon_data$sw_N_diffs <- NA
304-
codon_data$sw_S_diffs <- NA
305-
codon_data$sw_N_sites <- NA
306-
codon_data$sw_S_sites <- NA
307-
codon_data$sw_dN <- NA
308-
codon_data$sw_dS <- NA
309-
codon_data$sw_dNdS <- NA
310-
codon_data$sw_dN_m_dS <- NA
311-
codon_data$sw_boot_dN_SE <- NA
312-
codon_data$sw_boot_dS_SE <- NA
313-
codon_data$sw_boot_dN_over_dS_SE <- NA
314-
codon_data$sw_boot_dN_over_dS_P <- NA
315-
codon_data$sw_boot_dN_m_dS_SE <- NA
316-
codon_data$sw_boot_dN_m_dS_P <- NA
317-
codon_data$sw_boot_dN_gt_dS_count <- NA
318-
codon_data$sw_boot_dN_eq_dS_count <- NA
319-
codon_data$sw_boot_dN_lt_dS_count <- NA
320-
codon_data$sw_ASL_dN_gt_dS_P <- NA
321-
codon_data$sw_ASL_dN_lt_dS_P <- NA
322-
codon_data$sw_ASL_dNdS_P <- NA
299+
codon_data$sw_start <- as.double(NA)
300+
codon_data$sw_center <- as.double(NA)
301+
codon_data$sw_end <- as.double(NA)
302+
codon_data$sw_num_replicates <- as.integer(NA)
303+
codon_data$sw_N_diffs <- as.double(NA)
304+
codon_data$sw_S_diffs <- as.double(NA)
305+
codon_data$sw_N_sites <- as.double(NA)
306+
codon_data$sw_S_sites <- as.double(NA)
307+
codon_data$sw_dN <- as.double(NA)
308+
codon_data$sw_dS <- as.double(NA)
309+
codon_data$sw_dNdS <- as.double(NA)
310+
codon_data$sw_dN_m_dS <- as.double(NA)
311+
codon_data$sw_boot_dN_SE <- as.double(NA)
312+
codon_data$sw_boot_dS_SE <- as.double(NA)
313+
codon_data$sw_boot_dN_over_dS_SE <- as.double(NA)
314+
codon_data$sw_boot_dN_over_dS_P <- as.double(NA)
315+
codon_data$sw_boot_dN_m_dS_SE <- as.double(NA)
316+
codon_data$sw_boot_dN_m_dS_P <- as.double(NA)
317+
codon_data$sw_boot_dN_gt_dS_count <- as.integer(NA)
318+
codon_data$sw_boot_dN_eq_dS_count <- as.integer(NA)
319+
codon_data$sw_boot_dN_lt_dS_count <- as.integer(NA)
320+
codon_data$sw_ASL_dN_gt_dS_P <- as.double(NA)
321+
codon_data$sw_ASL_dN_lt_dS_P <- as.double(NA)
322+
codon_data$sw_ASL_dNdS_P <- as.double(NA)
323323

324324

325325
### PERFORM SLIDING WINDOW
326326
cat("Performing sliding window analysis...\n\n")
327327
for(this_frame in unique(codon_data$frame)) {
328-
#this_frame <- 'ss13'
328+
#this_frame <- 'sas13'
329329
frame_codon_data <- filter(codon_data, frame == this_frame, num_defined_seqs >= MIN_DEFINED_CODONS)
330330
frame_codon_data <- dplyr::arrange(frame_codon_data, codon_num)
331331

0 commit comments

Comments
 (0)