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

module data input #74

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 17 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
S3method(annotate_cell_type,HPCell)
S3method(calculate_pseudobulk,HPCell)
S3method(evaluate_hpc,HPCell)
S3method(get_single_cell,HPCell)
S3method(normalise_abundance_seurat_SCT,HPCell)
S3method(print,HPCell)
S3method(remove_dead_scuttle,HPCell)
S3method(remove_doublets_scDblFinder,HPCell)
S3method(remove_empty_DropletUtils,HPCell)
S3method(remove_empty_DropletUtils,Seurat)
S3method(remove_empty_threshold,HPCell)
S3method(remove_empty_threshold,Seurat)
S3method(score_cell_cycle_seurat,HPCell)
S3method(tranform_assay,HPCell)
export(alive_identification)
export(annotate_cell_type)
export(annotation_consensus)
Expand All @@ -18,15 +22,19 @@ export(calculate_pseudobulk)
export(cell_cycle_scoring)
export(convert_gene_names)
export(create_pseudobulk)
export(delete_lines_with_word)
export(doublet_identification)
export(empty_droplet_id)
export(empty_droplet_threshold)
export(evaluate_hpc)
export(expand_tiered_arguments)
export(factory_de_fix_effect)
export(factory_de_random_effect)
export(factory_split)
export(feature_chunks)
export(find_variable_genes)
export(get_positions)
export(get_single_cell)
export(get_unique_tissues)
export(initialise_hpc)
export(map2_test_differential_abundance_hpc)
Expand All @@ -39,20 +47,23 @@ export(map_test_differential_abundance)
export(non_batch_variation_removal)
export(normalise_abundance_seurat_SCT)
export(preprocessing_output)
export(preprocessing_output_factory)
export(pseudobulk_merge)
export(read_data_container)
export(reference_label_coarse_id)
export(reference_label_fine_id)
export(remove_dead_scuttle)
export(remove_doublets_scDblFinder)
export(remove_empty_DropletUtils)
export(remove_empty_threshold)
export(run_targets_pipeline)
export(save_experiment_data)
export(score_cell_cycle_seurat)
export(se_add_dispersion)
export(seurat_to_ligand_receptor_count)
export(split_summarized_experiment)
export(test_differential_abundance_hpc)
export(tranform_assay)
export(transform_utility)
export(vector_to_code)
exportMethods(test_differential_abundance)
import(SeuratObject)
Expand Down Expand Up @@ -119,7 +130,9 @@ importFrom(Seurat,ScaleData)
importFrom(Seurat,VariableFeatures)
importFrom(Seurat,as.Seurat)
importFrom(Seurat,as.SingleCellExperiment)
importFrom(SingleCellExperiment,"altExp<-")
importFrom(SingleCellExperiment,SingleCellExperiment)
importFrom(SingleCellExperiment,altExp)
importFrom(SingleR,SingleR)
importFrom(SummarizedExperiment,"assay<-")
importFrom(SummarizedExperiment,"colData<-")
Expand All @@ -129,6 +142,8 @@ importFrom(SummarizedExperiment,assay)
importFrom(SummarizedExperiment,assays)
importFrom(SummarizedExperiment,colData)
importFrom(SummarizedExperiment,rowData)
importFrom(biomaRt,getBM)
importFrom(biomaRt,useMart)
importFrom(callr,r)
importFrom(celldex,BlueprintEncodeData)
importFrom(celldex,MonacoImmuneData)
Expand Down Expand Up @@ -224,6 +239,7 @@ importFrom(targets,tar_script)
importFrom(tibble,as_tibble)
importFrom(tibble,enframe)
importFrom(tibble,rowid_to_column)
importFrom(tibble,rownames_to_column)
importFrom(tibble,tibble)
importFrom(tidybulk,as_SummarizedExperiment)
importFrom(tidybulk,pivot_transcript)
Expand Down
19 changes: 18 additions & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,21 @@
#'
#' @noRd
#'
"dummy_hpc"
"dummy_hpc"


#' A data frame of Ensembl genes retrieved from biomaRt package
#'
#' This dataset contains Ensembl gene IDs, external gene names, and chromosome names
#' retrieved using the biomaRt package.
#'
#' @format A data frame map of ensembl_gene_id, external_gene_name and chromosome_name
#'
#' @usage
#' data(ensembl_genes_biomart)
#'
#' @source biomaRt::getBM()
#'
#' @keywords datasets
#' @docType data
"ensembl_genes_biomart"
26 changes: 19 additions & 7 deletions R/factories.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ expand_tiered_arguments <- function(command, tiers, tiered_args) {
command_character = command |> deparse()

for(t in tiered_args){
command_character = command_character |> str_replace(t, paste0(t, "_", tiers) |> paste(collapse = ", "))
command_character = command_character |> str_replace(t, sprintf("c(%s)",
paste0(t, "_",
tiers) |>
paste(collapse = ", ")))
}

command_character |> rlang::parse_expr()
Expand All @@ -75,9 +78,10 @@ expand_tiered_arguments <- function(command, tiers, tiered_args) {


#' @importFrom stringr str_extract
#' @export
factory_split = function(
name_output, command, tiers, arguments_to_tier = c(), other_arguments_to_tier = c(),
other_arguments_to_map = c(), packages = targets::tar_option_get("packages")
other_arguments_to_map = c(), packages = targets::tar_option_get("packages") , ...
){

if(command |> deparse() |> str_detect("%>%") |> any())
Expand Down Expand Up @@ -123,7 +127,9 @@ factory_split = function(
else
resources = tar_resources(crew = tar_resources_crew(.y))


# # Process additional arguments in ...
# additional_args <- list(...)
#
tar_target_raw(
name = glue("{name_output}_{.y}") |> as.character(),
command = command |> add_tier_inputs(other_arguments_to_tier, .y),
Expand Down Expand Up @@ -204,7 +210,7 @@ factory_de_fix_effect = function(se_list_input, output_se, formula, method, tier


tar_target_raw("chunk_tbl",
pseudobulk_gran_group |>
pseudobulk_se |>
rownames() |>
feature_chunks() |>
quote()
Expand All @@ -213,7 +219,7 @@ factory_de_fix_effect = function(se_list_input, output_se, formula, method, tier

tar_target_raw(
"pseudobulk_group_list",
pseudobulk_gran_group |>
pseudobulk_se |>
group_split(!!sym(pseudobulk_group_by)) |>
quote(),
iteration = "list",
Expand Down Expand Up @@ -271,7 +277,7 @@ factory_de_random_effect = function(se_list_input, output_se, formula, tiers, fa

tar_target_raw(
"pseudobulk_group_list",
pseudobulk_gran_group |>
pseudobulk_se |>
group_split(!!sym(pseudobulk_group_by)) |>
quote(),
iteration = "list",
Expand All @@ -295,7 +301,13 @@ factory_de_random_effect = function(se_list_input, output_se, formula, tiers, fa
packages = c("tidySummarizedExperiment", "S4Vectors", "purrr", "dplyr" ,"tidybulk", "HPCell")
),

tar_target_raw("pseudobulk_table_dispersion_gene_unlist", pseudobulk_table_dispersion_gene |> unlist() |> quote(), iteration = "list"),
tar_target_raw(
"pseudobulk_table_dispersion_gene_unlist",
pseudobulk_table_dispersion_gene |> unlist() |> unlist() |> quote(),
iteration = "list"
#,
#pattern = map(pseudobulk_table_dispersion_gene) |> quote()
),

# Analyse
tar_target_raw(
Expand Down
Loading