Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop undefined datasets #81

Merged
merged 7 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
240 changes: 113 additions & 127 deletions R/functions.R

Large diffs are not rendered by default.

138 changes: 11 additions & 127 deletions R/modules_grammar_hpc.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,6 @@ remove_empty_DropletUtils.HPCell = function(input_hpc, total_RNA_count_check = N

}

target_chunk_undefined_remove_empty_DropletUtils = function(input_hpc){

input_hpc |>
hpc_iterate(
target_output = "empty_tbl",
user_function = (function(x) x |> as_tibble() |> select(.cell) |> mutate(empty_droplet = FALSE)) |> quote() ,
x = "data_object" |> is_target(),
packages = c("dplyr", "tidySingleCellExperiment", "tidyseurat")
)

}


# Define the generic function
#' @export
remove_dead_scuttle <- function(input_hpc,
Expand Down Expand Up @@ -246,20 +233,6 @@ remove_dead_scuttle.HPCell = function(

}

#' @importFrom dplyr mutate
target_chunk_undefined_remove_dead_scuttle = function(input_hpc){

input_hpc |>
hpc_iterate(
target_output = "alive_tbl",
user_function = (function(x) x |> as_tibble() |> select(.cell) |> mutate(alive = TRUE)) |> quote() ,
x = "data_object" |> is_target(),
packages = c("dplyr", "tidySingleCellExperiment", "tidyseurat")
)

}



# Define the generic function
#' @export
Expand All @@ -281,46 +254,28 @@ score_cell_cycle_seurat.HPCell = function(input_hpc, target_input = "data_object

}

target_chunk_undefined_score_cell_cycle_seurat = function(input_hpc, target_input = "data_object"){

input_hpc |>
hpc_iterate(
target_output = "cell_cycle_tbl",
user_function = function(x) NULL ,
x = "read_file_list" |> is_target()
)

}


# Define the generic function
#' @export
remove_doublets_scDblFinder <- function(input_hpc, target_input = "data_object", target_output = "doublet_tbl") {
remove_doublets_scDblFinder <- function(
input_hpc, target_input = "data_object", target_output = "doublet_tbl",
target_empry_droplets = "empty_tbl", target_alive = "alive_tbl"
) {
UseMethod("remove_doublets_scDblFinder")
}

#' @export
remove_doublets_scDblFinder.HPCell = function(input_hpc, target_input = "data_object", target_output = "doublet_tbl") {
remove_doublets_scDblFinder.HPCell = function(
input_hpc, target_input = "data_object", target_output = "doublet_tbl",
target_empry_droplets = "empty_tbl", target_alive = "alive_tbl"
) {

input_hpc |>
hpc_iterate(
target_output = target_output,
user_function = doublet_identification |> quote() ,
input_read_RNA_assay = target_input |> is_target(),
empty_droplets_tbl = "empty_tbl" |> is_target() ,
alive_identification_tbl = "alive_tbl" |> is_target()
)

}

target_chunk_undefined_remove_doublets_scDblFinder = function(input_hpc){

input_hpc |>
hpc_iterate(
target_output = "doublet_tbl",
user_function = (function(x) x |> as_tibble() |> select(.cell) |> mutate(scDblFinder.class="singlet")) |> quote() ,
x = "data_object" |> is_target(),
packages = c("dplyr", "tidySingleCellExperiment", "tidyseurat")
empty_droplets_tbl = target_empry_droplets |> is_target() ,
alive_identification_tbl = target_alive |> is_target()
)

}
Expand Down Expand Up @@ -355,19 +310,6 @@ annotate_cell_type.HPCell = function(input_hpc, azimuth_reference = NULL, target

}

target_chunk_undefined_annotate_cell_type = function(input_hpc){

input_hpc |>
hpc_iterate(
target_output = "annotation_tbl",
user_function = function(x) NULL ,
x = read_file_list |> quote()
)


}


# Define the generic function
#' @export
normalise_abundance_seurat_SCT <- function(input_hpc, target_input = "data_object", target_output = "sct_matrix", ...) {
Expand All @@ -391,18 +333,6 @@ normalise_abundance_seurat_SCT.HPCell = function(input_hpc, factors_to_regress =
)


}

target_chunk_undefined_normalise_abundance_seurat_SCT = function(input_hpc){

input_hpc |>
hpc_iterate(
target_output = "sct_matrix",
user_function = function(x) NULL ,
x = read_file_list |> quote()
)


}

# Define the generic function
Expand Down Expand Up @@ -466,7 +396,7 @@ get_single_cell.HPCell = function(input_hpc, target_input = "data_object", targe
user_function = preprocessing_output |> quote() ,
input_read_RNA_assay = target_input |> is_target(),
empty_droplets_tbl = "empty_tbl" |> is_target() ,
non_batch_variation_removal_S = sct_matrix |> quote(),
non_batch_variation_removal_S = "sct_matrix" |> is_target(),
alive_identification_tbl = "alive_tbl" |> is_target(),
cell_cycle_score_tbl = "cell_cycle_tbl" |> is_target(),
annotation_label_transfer_tbl = "annotation_tbl" |> is_target(),
Expand Down Expand Up @@ -577,52 +507,6 @@ evaluate_hpc <- function(input_hpc) {
#' @export
evaluate_hpc.HPCell = function(input_hpc) {

#-----------------------#
# Empty droplets
#-----------------------#

if(! "empty_tbl" %in% names(input_hpc))
target_chunk_undefined_remove_empty_DropletUtils(input_hpc)

#-----------------------#
# Annotate cell type
#-----------------------#

if(
!("annotation_tbl" %in% names(input_hpc) |
( "alive_tbl" %in% names(input_hpc) & !is.null(input_hpc$remove_dead_scuttle$group_by))
))
target_chunk_undefined_annotate_cell_type(input_hpc)

#-----------------------#
# Remove dead
#-----------------------#

if(! "alive_tbl" %in% names(input_hpc))
target_chunk_undefined_remove_dead_scuttle(input_hpc)


#-----------------------#
# score cell cycle
#-----------------------#
if(! "cell_cycle_tbl" %in% names(input_hpc))
target_chunk_undefined_score_cell_cycle_seurat(input_hpc)

#-----------------------#
# Doublets
#-----------------------#

if(! "doublet_tbl" %in% names(input_hpc))
target_chunk_undefined_remove_doublets_scDblFinder(input_hpc)

#-----------------------#
# SCT
#-----------------------#

if(! "sct_matrix" %in% names(input_hpc))
target_chunk_undefined_normalise_abundance_seurat_SCT(input_hpc)


#-----------------------#
# Close pipeline
#-----------------------#
Expand Down
2 changes: 1 addition & 1 deletion man/alive_identification.Rd

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

2 changes: 1 addition & 1 deletion man/annotation_label_transfer.Rd

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

2 changes: 1 addition & 1 deletion man/cell_cycle_scoring.Rd

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

10 changes: 5 additions & 5 deletions man/create_pseudobulk.Rd

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

4 changes: 2 additions & 2 deletions man/doublet_identification.Rd

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

6 changes: 3 additions & 3 deletions man/non_batch_variation_removal.Rd

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

10 changes: 5 additions & 5 deletions man/preprocessing_output.Rd

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

1 change: 0 additions & 1 deletion tests/testthat/test_single_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,6 @@ file_list |>
# Remove doublets
remove_doublets_scDblFinder(target_input = "data_object") |>


normalise_abundance_seurat_SCT(factors_to_regress = c(
"subsets_Mito_percent",
"subsets_Ribo_percent",
Expand Down
Loading