Skip to content

Error Fehler in all_fits[[i]]$result : $ when running the function fit_tissue #2

@SergejRuff

Description

@SergejRuff

Hello,

I was testing tissueResolver today using a pancreas dataset with a pseudo-bulk dataset generated via the Simbu package. My goal was to benchmark tissueResolver against other methods, including MuSiC, so I used the same pancreas islet dataset.

Unfortunately, tissueResolver did not work for me. When running the fit_tissue function, I encountered the following error:

fitted_tissue <- fit_tissue(bulk_matrix, counts(sc_pan), bootstrap = TRUE,
bootstrap_nruns = 5, bootstrap_pctcells = 10, ncores = 4)
bootstrap run 1 of 5 (using 110 cells)
fitting 10 bulks...
Fehler in all_fits[[i]]$result : $ operator is invalid for atomic vectors

Steps to Reproduce

  1. Import single-cell data

sc_pan_path <- "G:/tiergenomik/AG_bioinf/research/Ruff_Sergej/08_datacollection/pancreas_cells_one_condition/"
sc_pan <- readRDS(paste0(sc_pan_path, "sc_pancrease_healthy.rds"))

cell_types_to_keep <- c("delta", "alpha", "gamma", "ductal", "acinar", "beta")
sc_pan <- sc_pan[, sc_pan$cellType %in% cell_types_to_keep]
sc_pan$cellType <- factor(sc_pan$cellType, levels = cell_types_to_keep)
  1. Generate pseudo-bulk dataset
library(SimBu)

# Create annotation dataframe
ann_data_scpan <- data.frame(ID = rownames(colData(sc_pan)), cell_type = sc_pan$cellType)

# Create dataset object
dataset_scpan <- dataset(annotation = ann_data_scpan, count_matrix = counts(sc_pan), name = "sc_pan_healthy")

# Simulate pseudo-bulk
pseudobulk_pan <- simulate_bulk(
  data = dataset_scpan, scenario = "mirror_db", scaling_factor = "NONE",
  BPPARAM = SnowParam((detectCores()-1), stop.on.error = FALSE), nsamples = 10
)

# Assign to separate variables
bulk_matrix <- assay(pseudobulk_pan$bulk, 1, withDimnames = TRUE)
bulk_matrix <- as.matrix(bulk_matrix)
bulk_se <- pseudobulk_pan$bulk
ground_truth_proportions <- pseudobulk_pan$cell_fractions

  1. Run fit_tissue
fitted_tissue <- fit_tissue(bulk_matrix, counts(sc_pan), bootstrap = TRUE,
                            bootstrap_nruns = 5, bootstrap_pctcells = 10, ncores = 4)

Both bulk_matrix and counts(sc_pan) are matrix objects, as required by the function.

The example provided in the documentation runs successfully, but using real data does not.

I tested two other datasets, and they also failed with the same error.

Additional Issues:

The function documentation specifies that bulkRNA and single-cell data should be provided as data frames. However, when passing data frames, the function fails due to the promote_matrix function.

The sample function used in bootstrapping has replace = FALSE. Since bootstrapping typically involves sampling with replacement, shouldn't replace = TRUE be used instead?

I would appreciate any guidance on resolving this issue, as I would still like to benchmark tissueResolver. Additionally, I am willing to contribute to tissueResolver, but I am unsure if contributions are needed or welcomed.

Thank you for your time,
Sergej

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions