TobiTekath / DTUrtle

Perform differential transcript usage (DTU) analysis of bulk or single-cell RNA-seq data. See documentation at:
https://tobitekath.github.io/DTUrtle
GNU General Public License v3.0
17 stars 3 forks source link

Error in if (class(samples[, i]) == "character") samples[, i] <- factor(samples[, : the condition has length > 1 #26

Closed lscdanson closed 3 months ago

lscdanson commented 3 months ago

Hi I encountered the captioned error when running the run_drimseq() function. I'm running it on a Seurat object with transcript-level data integrated from 6 samples (3 treated; 3 untreated), so I skipped over the combine_to_matrix() function as it does not apply to my scenario and I'm not sure if this is causing the error I'm seeing. Please find below my analysis script:


title: "R Notebook" output: html_notebook

if(!requireNamespace("remotes", quietly = TRUE)){
    install.packages("remotes")
}
remotes::install_github("TobiTekath/DTUrtle")
library(Seurat)
library(dplyr)
library(DTUrtle)
biocpar <- BiocParallel::MulticoreParam(10)
so_trx <- readRDS("so_trx_pbmc_combined_condition_matched_pre_feature_selection.RDS")
so_trx
# subset to cell type of interest
so_trx_sub <- subset(so_trx, subset = celltype_paired=="Naive regulatory T (Treg) cell")
dim(so_trx_sub)
rownames(so_trx_sub@assays$originalexp@data) <- so_trx_sub@assays$originalexp@meta.features$transcript_name
rownames(so_trx_sub@assays$originalexp@counts) <- so_trx_sub@assays$originalexp@meta.features$transcript_name
so_trx_sub@assays$originalexp@data[1:4, 1:4]
tx2gene <- import_gtf(gtf_file = "Homo_sapiens.GRCh38.112.gtf")
head(tx2gene, n=3)
tx2gene$gene_name <- one_to_one_mapping(name = tx2gene$gene_name, id = tx2gene$gene_id)

tx2gene$transcript_name <- one_to_one_mapping(name = tx2gene$transcript_name, id = tx2gene$transcript_id)
tx2gene <- move_columns_to_front(df = tx2gene, columns = c("transcript_name", "gene_name"))
dturtle_sub <- run_drimseq(counts = so_trx_sub, pd = so_trx_sub@meta.data,
                           tx2gene = c("transcript_name", "gene_name"),
                           cond_col="condition", cond_levels = c("stimulated", "unstimulated"), 
                           filtering_strategy = "sc", BPPARAM = biocpar)
lscdanson commented 3 months ago

Problem has been solved after creating a pd separately instead of pointing to the meta.data slot of seurat object. Great deal of appreciation for this wonderfully built tool!

TobiTekath commented 3 months ago

@lscdanson Thank you very much for the kind words. And I am very glad you could resolve the problem by yourself in the end.

Hm, in theory the seurat meta.data slot should be usable here - the error hints to a problem with factor levels. I might have a look into that when I find the time.