Skip to content

Commit

Permalink
Editing red blood cell detection threshold ( != 0 to over 50)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlicenJoyHenning committed Sep 12, 2024
1 parent 51ee94a commit 6a2a0c4
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 78 deletions.
129 changes: 68 additions & 61 deletions R/limiric.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#' @param droplet_qc Verify output with droplet_qc, if TRUE velocyto_path must be given. Default is FALSE
#' @param velocyto_path Directory of 'Velocyto' filtered alignment output
#' @param filter_rbc Whether or not red blood cells should be removed. Default is TRUE
#' @param hemo_threshold Percent hemoglobin expression above which cells are filtered. Default is 50
#' @param isolate_cd45 Discard non-immune cells. Default is FALSE
#' @param filter_output Should output contain no damaged cells. Default is TRUE
#' @param output_path Directory where 'limiric' output should be generated
Expand Down Expand Up @@ -63,22 +64,23 @@ utils::globalVariables(c(

limiric <- function(

project_name = NULL,
filtered_path = NULL,
seurat_input = NULL,
min_cells = NULL,
soupx = NULL,
raw_path = NULL,
droplet_qc = NULL,
velocyto_path = NULL,
filter_rbc = NULL,
isolate_cd45 = NULL,
filter_output = NULL,
output_path = NULL,
organism = NULL,
resolution = NULL,
cluster_ranks = NULL,
sample_list = NULL
project_name = NULL,
filtered_path = NULL,
seurat_input = NULL,
min_cells = NULL,
soupx = NULL,
raw_path = NULL,
droplet_qc = NULL,
velocyto_path = NULL,
filter_rbc = NULL,
hemo_threshold = NULL,
isolate_cd45 = NULL,
filter_output = NULL,
output_path = NULL,
organism = NULL,
resolution = NULL,
cluster_ranks = NULL,
sample_list = NULL

){

Expand All @@ -96,28 +98,30 @@ limiric <- function(
if (is.null(soupx)) {soupx = FALSE}
if (is.null(droplet_qc)) {droplet_qc = FALSE}
if (is.null(filter_rbc)) {filter_rbc = TRUE}
if (is.null(hemo_threshold)){hemo_threshold = 50}
if (is.null(isolate_cd45)) {isolate_cd45 = FALSE}
if (is.null(filter_output)) {filter_output = TRUE}
if (is.null(organism)) {organism = "Hsap"}

# Run single sample using the limiric_core function
result <- limiric_core(

project_name = project_name,
filtered_path = filtered_path,
seurat_input = seurat_input,
min_cells = min_cells,
resolution = resolution,
cluster_ranks = cluster_ranks,
soupx = soupx,
raw_path = raw_path,
droplet_qc = droplet_qc,
velocyto_path = velocyto_path,
filter_rbc = filter_rbc,
isolate_cd45 = isolate_cd45,
filter_output = filter_output,
output_path = output_path,
organism = organism
project_name = project_name,
filtered_path = filtered_path,
seurat_input = seurat_input,
min_cells = min_cells,
resolution = resolution,
cluster_ranks = cluster_ranks,
soupx = soupx,
raw_path = raw_path,
droplet_qc = droplet_qc,
velocyto_path = velocyto_path,
filter_rbc = filter_rbc,
hemo_threshold = hemo_threshold,
isolate_cd45 = isolate_cd45,
filter_output = filter_output,
output_path = output_path,
organism = organism

)

Expand Down Expand Up @@ -162,21 +166,22 @@ limiric <- function(
sample <- sample_list[[i]]

# Define the inputs from the list
project_name <- sample$project_name
filtered_path <- sample$filtered_path
seurat_input <- sample$seurat_input
min_cells <- sample$min_cells
resolution <- sample$resolution
cluster_ranks <- sample$cluster_ranks
soupx <- sample$soupx
raw_path <- sample$raw_path
droplet_qc <- sample$droplet_qc
velocyto_path <- sample$velocyto_path
filter_rbc <- sample$filter_rbc
isolate_cd45 <- sample$isolate_cd45
filter_output <- sample$filter_output
output_path <- sample$output_path
organism <- sample$organism
project_name <- sample$project_name
filtered_path <- sample$filtered_path
seurat_input <- sample$seurat_input
min_cells <- sample$min_cells
resolution <- sample$resolution
cluster_ranks <- sample$cluster_ranks
soupx <- sample$soupx
raw_path <- sample$raw_path
droplet_qc <- sample$droplet_qc
velocyto_path <- sample$velocyto_path
filter_rbc <- sample$filter_rbc
hemo_threshold <- sample$hemo_threshold
isolate_cd45 <- sample$isolate_cd45
filter_output <- sample$filter_output
output_path <- sample$output_path
organism <- sample$organism

# Account for defaults
if (is.null(seurat_input)) {seurat_input = NULL}
Expand All @@ -186,6 +191,7 @@ limiric <- function(
if (is.null(soupx)) {soupx = FALSE}
if (is.null(droplet_qc)) {droplet_qc = FALSE}
if (is.null(filter_rbc)) {filter_rbc = TRUE}
if (is.null(hemo_threshold)){hemo_threshold = 50}
if (is.null(isolate_cd45)) {isolate_cd45 = FALSE}
if (is.null(filter_output)) {filter_output = TRUE}
if (is.null(organism)) {organism = "Hsap"}
Expand All @@ -197,21 +203,22 @@ limiric <- function(

temp_result <- limiric_core(

project_name = project_name,
filtered_path = filtered_path,
seurat_input = seurat_input,
min_cells = min_cells,
resolution = resolution,
cluster_ranks = cluster_ranks,
soupx = soupx,
raw_path = raw_path,
droplet_qc = droplet_qc,
velocyto_path = velocyto_path,
filter_rbc = filter_rbc,
isolate_cd45 = isolate_cd45,
filter_output = filter_output,
output_path = output_path,
organism = organism
project_name = project_name,
filtered_path = filtered_path,
seurat_input = seurat_input,
min_cells = min_cells,
resolution = resolution,
cluster_ranks = cluster_ranks,
soupx = soupx,
raw_path = raw_path,
droplet_qc = droplet_qc,
velocyto_path = velocyto_path,
filter_rbc = filter_rbc,
hemo_threshold = hemo_threshold,
isolate_cd45 = isolate_cd45,
filter_output = filter_output,
output_path = output_path,
organism = organism

)

Expand Down
33 changes: 17 additions & 16 deletions R/limiric_core.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#' @param raw_path Directory of unfiltered alignment output
#' @param droplet_qc Verify output with droplet_qc, if TRUE velocyto_path must be given. Default is FALSE
#' @param velocyto_path Directory of Veocyto filtered alignment output
#' @param filter_rbc Whether or not red blood cells should be removed, Default is TRUE
#' @param filter_rbc Whether or not red blood cells should be removed. Default is TRUE
#' @param hemo_threshold Percent hemoglobin expression above which cells are filtered. Default is 50
#' @param isolate_cd45 Discard non-immune cells. Default is FALSE
#' @param filter_output Should output contain no damaged cells. Default is TRUE
#' @param output_path Directory where limiric output cen be generated
Expand Down Expand Up @@ -62,19 +63,20 @@ utils::globalVariables(c(
limiric_core <- function(
project_name,
filtered_path,
seurat_input = NULL,
min_cells = 0,
soupx = FALSE,
raw_path = NULL,
droplet_qc = FALSE,
velocyto_path = NULL,
filter_rbc = TRUE,
isolate_cd45 = FALSE,
filter_output = TRUE,
output_path = "./",
resolution = 1,
cluster_ranks = 1,
organism = "Hsap"
seurat_input = NULL,
min_cells = 0,
soupx = FALSE,
raw_path = NULL,
droplet_qc = FALSE,
velocyto_path = NULL,
filter_rbc = TRUE,
hemo_threshold = 50,
isolate_cd45 = FALSE,
filter_output = TRUE,
output_path = "./",
resolution = 1,
cluster_ranks = 1,
organism = "Hsap"
){
# Receive & prepare input ------------------------------------

Expand Down Expand Up @@ -248,8 +250,7 @@ limiric_core <- function(
)

# Label barcodes if they are likely RBCs or have hemoglobin contamination
# WANT TO EDIT TO INTRODUCE A RANGE
Seurat[['RBC']] <- ifelse(Seurat$hemo.percent != 0, "RBC", "non-RBC")
Seurat[['RBC']] <- ifelse(Seurat$hemo.percent >= hemo_threshold, "RBC", "non-RBC")

# Calculate the number of RBCs (account for none)
RBC_number <- NULL
Expand Down
2 changes: 2 additions & 0 deletions man/limiric.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/limiric_core.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6a2a0c4

Please sign in to comment.