Skip to content

Commit

Permalink
fixed problem with latest version of flowCore, closes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
pfgherardini committed Jun 4, 2018
1 parent 90abbe2 commit 2568d67
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 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.1.7
Version: 0.1.8
Author: "Pier Federico Gherardini <pfgherardini@parkerici.org> [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
Expand Down
26 changes: 11 additions & 15 deletions R/fcs_io.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,6 @@ update_flowFrame_keywords <- function(flowFrame, exprs.m, desc = NULL, data.rang
return(flowFrame)
}

copy_keywords_name_desc <- function(source.frame, target.frame) {
source.keywords <- flowCore::keyword(source.frame)

for (i in 1:ncol(target.frame)) {
s <- paste("$P",i,"S",sep="")
n <- paste("$P",i,"N",sep="")

if(!is.null(source.keywords[[s]]))
flowCore::keyword(target.frame) <- source.keywords[s]

if(!is.null(source.keywords[[n]]))
flowCore::keyword(target.frame) <- source.keywords[n]
}
return(target.frame)
}

#' Copy FCS keywords from a source to a target flowFrame object
#'
Expand Down Expand Up @@ -115,6 +100,14 @@ as_flowFrame <- function(exprs.m, source.frame = NULL) {
kw.list <- c(kw.list, paste("$P", 1:num.cols, "N", sep = ""))
kw.list <- c(kw.list, "$CYT", "$CYTSN", "$DATE", "$FIL", "$BTIM", "$ETIM")
flow.frame <- copy_keywords(source.frame, flow.frame, kw.list)
marker.names <- as.character(flowCore::parameters(source.frame)$desc)
names(marker.names) <- as.character(flowCore::parameters(source.frame)$name)

# Use the channel name for channels where the description is missing
w <- is.na(marker.names)
marker.names[w] <- names(marker.names)[w]

flowCore::markernames(flow.frame) <- marker.names
}
return(flow.frame)

Expand Down Expand Up @@ -154,6 +147,9 @@ write_fcs <- function(fcs, out.name) {
flow.frame <- flowCore::flowFrame(fcs$m)
flow.frame <- update_flowFrame_keywords(flow.frame, fcs$m, fcs$desc, data.range = 262144)
flowCore::keyword(flow.frame) <- keys
marker.names <- fcs$desc
names(marker.names) <- colnames(fcs$m)
flowCore::markernames(flow.frame) <- marker.names
write_flowFrame(flow.frame, out.name)
}

Expand Down

0 comments on commit 2568d67

Please sign in to comment.