Skip to content

Commit 2ad7eee

Browse files
committed
Added channel selection for min and max margins in RemoveMargins + added an attribute ("margin_matrix") to the resulting flowframe with the margin counts
1 parent f2f847d commit 2ad7eee

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

R/PeacoQC.R

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#' found back in \code{colnames(flowCore::exprs(ff))}. If a channel is not
1818
#' listed in this parameter, its default internal values will be used. The
1919
#' default of this parameter is NULL.
20+
#' @param remove_min The channel indices or channel names that have to be checked
21+
#' for minimum margins. The default of this parameter is channels.
22+
#' @param remove_max The channel indices or channel names that have to be checked
23+
#' for maximum margins. The default of this parameter is channels.
2024
#' @param output If set to "full", a list with the filtered flowframe and the
2125
#' indices of the margin event is returned. If set to "frame", only the
2226
#' filtered flowframe is returned. The default is "frame".
@@ -54,7 +58,9 @@ RemoveMargins <- function(
5458
ff,
5559
channels,
5660
channel_specifications=NULL,
57-
output="frame") {
61+
output="frame",
62+
remove_min = channels,
63+
remove_max = channels) {
5864

5965
if (!is(ff, "flowFrame"))
6066
stop("ff should be a flowframe.")
@@ -96,11 +102,21 @@ RemoveMargins <- function(
96102
channels <- colnames(flowCore::exprs(ff))[channels]
97103
}
98104
# Make selection
105+
margin_matrix <- matrix(nrow = length(channels), ncol = 2, dimnames = list(channels, c("min", "max")))
99106
for (d in channels) {
100107

101-
selection <- selection &
102-
e[, d] > max(min(meta[d, "minRange"], 0), min(e[, d])) &
103-
e[, d] < min(meta[d, "maxRange"], max(e[, d]))
108+
if(d %in% remove_min){
109+
min_margin_ev <- e[, d] <= max(min(meta[d, "minRange"], 0), min(e[, d]))
110+
margin_matrix[d, "min"] <- sum(min_margin_ev)
111+
selection <- selection & !min_margin_ev
112+
}
113+
if(d %in% remove_max){
114+
max_margin_ev <- e[, d] > min(meta[d, "maxRange"], max(e[, d]))
115+
margin_matrix[d, "max"] <- sum(max_margin_ev)
116+
selection <- selection & !max_margin_ev
117+
118+
}
119+
104120
}
105121

106122
if ((length(flowCore::keyword(ff)$FILENAME) > 0) &&
@@ -120,6 +136,7 @@ RemoveMargins <- function(
120136
}
121137

122138
new_ff <- ff[selection, ]
139+
attr(new_ff, "margin_matrix") <- margin_matrix
123140
if (!("Original_ID" %in% colnames(flowCore::exprs(new_ff)))){
124141
new_ff <- AppendCellID(new_ff, which(selection))}
125142
if (output == "full"){

man/RemoveMargins.Rd

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy