Skip to content

Commit

Permalink
Fix Time issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AnneliesEmmaneel committed Aug 18, 2023
1 parent 0a04a08 commit f2f847d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: PeacoQC
Title: Peak-based selection of high quality cytometry data
Version: 1.11.1
Version: 1.11.2
Authors@R:
person(given = "Annelies",
family = "Emmaneel",
Expand Down
6 changes: 6 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
PeacoQC (version 1.11.2)
------------------------

Fix time bugs
================================================================================

PeacoQC (version 1.11.1)
------------------------

Expand Down
13 changes: 10 additions & 3 deletions R/PeacoQC.R
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,14 @@ PlotPeacoQC <- function(ff,

# Check for time channel
if (!is.null(time_channel_parameter)){
if (all(!grepl(time_channel_parameter,
colnames(flowCore::exprs(ff)),
ignore.case=TRUE))){
time_channel <- NULL
} else{
time_channel <- grep(time_channel_parameter,
colnames(flowCore::exprs(ff)),
ignore.case=TRUE)
ignore.case=TRUE)}
} else(time_channel <- NULL)

if (is.numeric(channels)){
Expand Down Expand Up @@ -687,9 +692,11 @@ PlotPeacoQC <- function(ff,
if (!is.null(time_channel)){
if (is(display_peaks, "list") && display_peaks$Analysis != FALSE){
p_time <- BuildTimePlot(ff, blocks$overview_blocks_time,
scores_time, time_unit)
scores_time, time_unit,
time_id = time_channel)
} else{ p_time <- BuildTimePlot(ff, scores_time=scores_time,
time_unit=time_unit) }
time_unit=time_unit,
time_id = time_channel) }

plot_list[["Time"]] <- p_time

Expand Down
14 changes: 7 additions & 7 deletions R/PlotPeacoQC_helper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ MakeOverviewBlocks <- function(ff, peaks, time_channel){
overview_blocks_time <- NULL
if (length(time_channel) > 0){

x_min <- flowCore::exprs(ff)[, "Time"][c(1,
x_min <- flowCore::exprs(ff)[, time_channel][c(1,
cumsum(run_length$lengths)[-length(run_length$lengths)])]
x_max <- flowCore::exprs(ff)[, "Time"][cumsum(run_length$lengths)]
x_max <- flowCore::exprs(ff)[, time_channel][cumsum(run_length$lengths)]

overview_blocks_time <- data.frame(x_min=x_min,
x_max=x_max,
Expand Down Expand Up @@ -75,21 +75,21 @@ MakeManualBlocks <- function(manual_cells){
}


BuildTimePlot <- function(ff, blocks=NULL, scores_time, time_unit=100){
BuildTimePlot <- function(ff, blocks=NULL, scores_time, time_unit=100, time_id){
if (nrow(ff) >=50000) {
subset_timeplot <- sort(sample(seq_len(nrow(ff)), 50000))
} else {
subset_timeplot <- seq_len(nrow(ff))
}


h <- graphics::hist(flowCore::exprs(ff)[subset_timeplot, "Time"],
breaks=seq(min(flowCore::exprs(ff)[, "Time"]),
max(flowCore::exprs(ff)[, "Time"]) +
h <- graphics::hist(flowCore::exprs(ff)[subset_timeplot, time_id],
breaks=seq(min(flowCore::exprs(ff)[, time_id]),
max(flowCore::exprs(ff)[, time_id]) +
time_unit, by=time_unit),
plot=FALSE)

idcs <- findInterval(flowCore::exprs(ff)[subset_timeplot, "Time"], h$breaks)
idcs <- findInterval(flowCore::exprs(ff)[subset_timeplot, time_id], h$breaks)

p_time <- ggplot() + theme_bw()

Expand Down

0 comments on commit f2f847d

Please sign in to comment.