Skip to content

Commit

Permalink
added more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
pfgherardini committed Feb 13, 2022
1 parent 89c5fee commit e05eb53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: premessa
Type: Package
Title: R package for pre-processing of flow and mass cytometry data
Version: 0.3.1
Version: 0.3.2
Author: "Pier Federico Gherardini <federico.gherardini@gmail.com> [aut, cre]"
Description: This package includes panel editing/renaming for FCS files, bead-based normalization and debarcoding.
Imports: shiny (>= 0.14), flowCore, reshape, ggplot2, hexbin, gridExtra, rhandsontable, jsonlite, data.table, shinyjqui
Expand Down
12 changes: 10 additions & 2 deletions R/normalize_cytof.R
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ normalize_folder <- function(wd, output.dir.name, beads.gates, beads.type, basel
out.dir.path <- file.path(wd, output.dir.name)
beads.dir.path <- file.path(out.dir.path, "beads")
beads.vs.time.path <- file.path(out.dir.path, "beads_vs_time")
#This will also create the upstram out.dir.path
#This will also create the upstream out.dir.path
dir.create(beads.dir.path, recursive = T)
dir.create(beads.vs.time.path, recursive = T)

Expand Down Expand Up @@ -283,13 +283,16 @@ normalize_folder <- function(wd, output.dir.name, beads.gates, beads.type, basel

beads.normed <- apply(norm.res$beads.normed[, beads.cols], 2, median)
beads.smoothed <- apply(norm.res$beads.smoothed[, beads.cols], 2, median)
beads.slopes <- median(norm.res$beads.slopes[, 2])

p <- plot_beads_over_time(norm.res$beads.smoothed, smooth_beads(norm.res$beads.normed), beads.cols)

ggplot2::ggsave(file.path(beads.vs.time.path, gsub(".fcs$", ".pdf", f.name, ignore.case = T)), plot = p, width = 11, height = 8.5, units = "in")
return(list(beads.normed = beads.normed, beads.smoothed = beads.smoothed))
return(list(beads.normed = beads.normed, beads.smoothed = beads.smoothed, beads.slopes = beads.slopes))
})

beads.slopes <- data.frame(slope = sapply(ll, "[[", "beads.slopes"), sample = names(beads.gates))

beads.medians <- t(sapply(ll, function(x) {return(x[["beads.normed"]])}))
beads.medians <- rbind(beads.medians,
t(sapply(ll, function(x) {return(x[["beads.smoothed"]])})))
Expand All @@ -299,7 +302,12 @@ normalize_folder <- function(wd, output.dir.name, beads.gates, beads.type, basel
beads.medians$sample <- rep(names(beads.gates), 2)
beads.medians$type <- c(rep("After", length(ll)), rep("Before", length(ll)))
beads.medians$type <- factor(beads.medians$type, levels = c("Before", "After"))

write.table(beads.slopes, file.path(out.dir.path, "beads_slopes.tsv"), row.names = FALSE, col.names = TRUE, sep = "\t", quote = F)
write.table(beads.medians, file.path(out.dir.path, "beads_medians.tsv"), row.names = FALSE, col.names = TRUE, sep = "\t", quote = F)

p <- plot_beads_medians(beads.medians)
ggplot2::ggsave(file.path(out.dir.path, "beads_before_and_after.pdf"), plot = p, width = 11, height = 8.5, units = "in")

}

0 comments on commit e05eb53

Please sign in to comment.