Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimens committed Mar 3, 2022
1 parent c2048f3 commit 47fa7ae
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .misc/meta.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = "3.6.2" %}
{% set version = "3.6.3" %}
{% set sha256 = "0f0998ecd50b586d69b50e53d9a0b3d5aa3afa70bd96fe85c2fa3ba02e58278b" %}

package:
Expand Down
4 changes: 2 additions & 2 deletions scripts/LASummary.r
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env Rscript

library(dplyr)
library(tidyr)
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(tidyr))
library(ggplot2)
library(readr)

Expand Down
4 changes: 2 additions & 2 deletions scripts/LepWrapTrim.r
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env Rscript

library(dplyr)
library(tidyr)
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(tidyr))
library(ggplot2)

args <- commandArgs(trailingOnly = TRUE)
Expand Down
69 changes: 34 additions & 35 deletions scripts/MapSummary.r
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,46 @@ if (file_test("-f", args[1])) {

# if args[1] is the target directory
} else if (file_test("-d", args[1])) {
library(stringr)
targetdir <- args[1]
library(stringr)
targetdir <- args[1]

# pattern match to find the map files
flist <- list.files(targetdir, full.names = TRUE, pattern = "^LOD.")
# natural language sort
flist <- str_sort(flist, numeric = TRUE)
# pattern match to find the map files
flist <- list.files(targetdir, full.names = TRUE, pattern = "^LOD.")
# natural language sort
flist <- str_sort(flist, numeric = TRUE)

for (i in flist){
# pull the file name from the end
mapfile <- tail(strsplit(i, "\\/")[[1]], n = 1)
# pull out the LOD value
lod<- strsplit(mapfile, "\\.")[[1]][2]
# read in the file
.dat <- read.table(i, header = FALSE, skip = 1)
# make a table of counts
.counts <- as.data.frame(table(.dat$V1))
# rename columns
names(.counts) <- c("LG", paste0("LOD.", lod))
if (i == flist[1]){
# if it's the first file, instantiate the counts dataframe
summtable <- .counts
} else {
# otherwise do a matchy-matchy (outer join) to update/bind the dataframe
summtable <- merge(summtable, .counts, by = "LG", all.x = TRUE, all.y = TRUE)
for (i in flist){
# pull the file name from the end
mapfile <- tail(strsplit(i, "\\/")[[1]], n = 1)
# pull out the LOD value
lod<- strsplit(mapfile, "\\.")[[1]][2]
# read in the file
.dat <- read.table(i, header = FALSE, skip = 1)
# make a table of counts
.counts <- as.data.frame(table(.dat$V1))
# rename columns
names(.counts) <- c("LG", paste0("LOD.", lod))
if (i == flist[1]){
# if it's the first file, instantiate the counts dataframe
summtable <- .counts
} else {
# otherwise do a matchy-matchy (outer join) to update/bind the dataframe
summtable <- merge(summtable, .counts, by = "LG", all.x = TRUE, all.y = TRUE)
}
}
}

# replace NA's as 0
summtable[is.na(summtable)] <- 0
summtable <- summtable[order(summtable$LG),]

# generate output filenames
out_tmp <-paste0(targetdir, "/.all.LOD.summary")
out_file <- paste0(targetdir, "/all.LOD.summary")
# replace NA's as 0
summtable[is.na(summtable)] <- 0
summtable <- summtable[order(summtable$LG),]

write.table(summtable, file = out_tmp, quote = FALSE, row.names = FALSE, col.names = TRUE)
# use GNU column command to make the table fixed-width and remove the tmp file
cmd <- paste("column -t", out_tmp, ">", out_file, "&& rm", out_tmp)
system(cmd)
# generate output filenames
out_tmp <-paste0(targetdir, "/.all.LOD.summary")
out_file <- paste0(targetdir, "/all.LOD.summary")

write.table(summtable, file = out_tmp, quote = FALSE, row.names = FALSE, col.names = TRUE)
# use GNU column command to make the table fixed-width and remove the tmp file
cmd <- paste("column -t", out_tmp, ">", out_file, "&& rm", out_tmp)
system(cmd)
} else {
cat("Error: the argument must be either a mapfile or a directory of mapfiles")
}
4 changes: 2 additions & 2 deletions scripts/MarkerPlot.r
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env Rscript

library(dplyr)
library(tidyr)
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(tidyr))
library(ggplot2)

args <- commandArgs(trailingOnly = TRUE)
Expand Down
6 changes: 3 additions & 3 deletions scripts/RecombinationSummary.r
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#! /usr/bin/env Rscript

# This script will parse all the recombination logs of LepWrap
library(dplyr)
library(tidyr)
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(tidyr))
library(stringr)
library(purrr)
suppressPackageStartupMessages(library(purrr))

## setup outfile
# format trailing arguments for script
Expand Down
7 changes: 3 additions & 4 deletions scripts/TrimSummaryPlot.r
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env Rscript

suppressMessages(library(dplyr))
suppressPackageStartupMessages((library(tidyr))
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(tidyr))
library(ggplot2)
library(readr)

Expand All @@ -28,5 +28,4 @@ tbl %>%
) +
scale_y_continuous(limits = c(-0.05, max(tbl$n_removed)+10))

ggsave(paste0(args[1], ".pdf"), height = 4, width = 7, units = "in")
#ggsave(paste0(args[1], ".svg"), height = 4, width = 7, units = "in")
ggsave(paste0(args[1], ".pdf"), height = 4, width = 7, units = "in")

0 comments on commit 47fa7ae

Please sign in to comment.