Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 0 additions & 92 deletions bin/config_CP_input_dauer.R

This file was deleted.

80 changes: 0 additions & 80 deletions bin/config_CP_input_toxin.R

This file was deleted.

72 changes: 72 additions & 0 deletions bin/makeMetadata_dauer.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env -S Rscript --vanilla
library(dplyr)
library(tidyr)
library(tibble)
library(stringr)
library(readr)
library(purrr)
library(data.table)

#==============================================================================#
# Arguments
#==============================================================================#
# 1 - A list of input files
# 2 - the path to the well_mask - HARDCODE NOW
# 3 - the group argument from main.nf - default is "plate,well"
# 4 - the edited pipeline path
# 5 - the out path
args <- commandArgs(trailingOnly = TRUE)
#==============================================================================#
# Make Metadata NEEDS TO BE ADAPATBLE TO MULTIPLE WAVELENGTHS
#==============================================================================#
# parse file names from directory - need wavelength in file name
meta1 <- read_delim(
args[1],
col_names = FALSE,
delim = "\t") %>%
select(file_path = X1) %>%
extract(file_path, into = "file", remove = FALSE, regex = ".*/(.*)$") %>%
extract(file,
remove = FALSE,
regex = "^(.*)-(.*)-(.*)-(.*)_(.*)_(.*)\\.(.*)$",
into = c("date","exp","plate","mag","well","wave","TIF")) %>%
select(-TIF) %>%
dplyr::mutate(row = stringr::str_extract(well, pattern = "[A-Z]"),
col = stringr::str_extract(well, pattern = "[0-9][0-9]"),
Image_PathName_wellmask_98.png = stringr::str_replace(args[2], pattern = "([^/]+$)", replacement = ""),
Image_FileName_wellmask_98.png = stringr::str_extract(args[2], pattern = "([^/]+$)"))

# add group
groups <- stringr::str_split(args[3], pattern = ",")[[1]]
meta1$group <- apply( meta1[, groups], 1, paste, collapse = "_")

# add image types and set metadata names - hardcode image names - needs to be flexible for multiple pipeline profiles
meta2 <- meta1 %>%
tidyr::pivot_wider(names_from = wave, values_from = c(file, file_path), ) %>%
dplyr::rename(Image_FileName_RawBF = file_w1,
Image_PathName_RawBF = file_path_w1,
Image_FileName_RawRFP = file_w2,
Image_PathName_RawRFP = file_path_w2) %>%
dplyr::mutate(
Image_PathName_RawRFP = stringr::str_replace(
Image_PathName_RawRFP, pattern = "([^/]+$)", replacement = ""
),
Image_PathName_RawBF = stringr::str_replace(
Image_PathName_RawBF, pattern = "([^/]+$)", replacement = ""
)
) %>%
dplyr::select(
Metadata_Experiment = exp,
Metadata_Date = date,
Metadata_Plate = plate,
Metadata_Well = well,
Metadata_Group = group,
Metadata_Magnification = mag,
Image_FileName_RawBF,
Image_PathName_RawBF,
Image_FileName_RawRFP,
Image_PathName_RawRFP,
Image_FileName_wellmask_98.png,
Image_PathName_wellmask_98.png)

write.table(meta2, file = "metadata.csv", quote=FALSE, sep=',', row.names = F)
58 changes: 58 additions & 0 deletions bin/makeMetadata_toxin.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env -S Rscript --vanilla
library(dplyr)
library(tidyr)
library(tibble)
library(stringr)
library(readr)
library(purrr)
library(data.table)

#==============================================================================#
# Arguments
#==============================================================================#
# 1 - A list of input files
# 2 - the path to the well_mask - HARDCODE NOW
# 3 - the group argument from main.nf - default is "plate,well"
# 4 - the edited pipeline path
# 5 - the out path
args <- commandArgs(trailingOnly = TRUE)

#==============================================================================#
# Make Metadata NEEDS TO BE ADAPATBLE TO MULTIPLE WAVELENGTHS
#==============================================================================#
# parse file names from directory - need wavelength in file name
meta1 <- read_delim(
args[1],
col_names = FALSE,
delim = "\t") %>%
select(file_path = X1) %>%
extract(file_path, into = "file", remove = FALSE, regex = ".*/(.*)$") %>%
extract(file,
remove = FALSE,
regex = "^(.*)-(.*)-(.*)-(.*)_(.*)\\.(.*)$",
into = c("date","exp","plate","mag","well","TIF")) %>%
select(-TIF) %>%
dplyr::mutate(row = stringr::str_extract(well, pattern = "[A-Z]"),
col = stringr::str_extract(well, pattern = "[0-9][0-9]"),
Image_PathName_wellmask_98.png = stringr::str_replace(args[2], pattern = "([^/]+$)", replacement = ""),
Image_FileName_wellmask_98.png = stringr::str_extract(args[2], pattern = "([^/]+$)"))

# add group
groups <- stringr::str_split(args[3], pattern = ",")[[1]]
meta1$group <- apply( meta1[, groups], 1, paste, collapse = "_")

# add image types and set metadata names - hardcode image names - needs to be flexible for multiple pipeline profiles
meta2 <- meta1 %>%
dplyr::mutate(Image_PathName_RawBF = stringr::str_replace(file_path, pattern = "([^/]+$)", replacement = "")) %>%
dplyr::select(Metadata_Experiment = exp,
Metadata_Date = date,
Metadata_Plate = plate,
Metadata_Well = well,
Metadata_Group = group,
Metadata_Magnification = mag,
Image_FileName_RawBF = file,
Image_PathName_RawBF,
Image_FileName_wellmask_98.png,
Image_PathName_wellmask_98.png)

write.table(meta2, file = "metadata.csv", quote=FALSE, sep=',', row.names = F)
16 changes: 7 additions & 9 deletions bin/proc_CP_output_dauer.R → bin/proc_CP_output.R
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# /usr/bin/Rscript
#!/usr/bin/env -S Rscript --vanilla
library(fs)
library(dplyr)
library(tidyr)
library(tibble)
library(stringr)
library(readr)
library(glue)
library(purrr)

#==============================================================================#
# Arguments
#==============================================================================#
# 1 - out directory path
# 2 - project name
# 3 - run stamp
args <- commandArgs(trailingOnly = TRUE)

#==============================================================================#
# Read CP output data
#==============================================================================#
# get the output for each model
dir <- glue::glue("{args[1]}/processed_data")
dir <- "processed_data"

# read in files and manipulate with
model_df <- dir %>%
Expand All @@ -36,10 +37,7 @@ model_df_list <- split.data.frame(model_df, model_df$model)
lapply(seq_along(model_df_list), function(i) assign(names(model_df_list)[i], model_df_list[[i]], envir = .GlobalEnv))

# save as R.data
proj_name <- stringr::str_extract(args[1], pattern = "[^\\/]+(?=(?:\\/[^\\/]+){1}$)")
run_stamp <- stringr::str_extract(args[1], pattern = "([^/]+$)")
proj_name <- args[1]
run_stamp <- args[2]
save(list = c(ls(pattern = "model.outputs")),
file = glue::glue("{args[1]}/processed_data/{proj_name}_{run_stamp}.RData"))

# clean up extra CP_outputs for now
system(command = glue::glue("if [ -d {args[1]}/CP_output ]; then rm -Rf {args[1]}/CP_output; fi"))
file = paste0("processed_data/", args[1], "_", args[2], ".RData"))
45 changes: 0 additions & 45 deletions bin/proc_CP_output_toxin.R

This file was deleted.

Loading