How to solve error when annotating cell type with CellAssign
Entering edit mode
4 months ago

I want to use CellAssign to annotate scRNA-seq data, but I faced the error and I don't know how to solve it. Could anyone help me?

This is my code:

rowdata <- rownames(N_data)
coldata <- colnames(N_data)

sce <- SingleCellExperiment(assays = list(counts = as.matrix(N_data)),colData = coldata,rowData = rowdata)
sce <- computeSumFactors(sce)
sce_Size_factors <- sizeFactors(sce)

cellassign_fit <- cellassign(exprs_obj = sce[rownames(marker_new),], 
                               marker_gene_info = as.matrix(marker_new), 
                               s = sce_Size_factors, 
                               learning_rate = 1e-2, 
                               shrinkage = TRUE,
                               verbose = TRUE)

The marker_new is the gene-by-cell-type binary matrix of marker. It was constructed as the cellassign.html required.I downloaded the processed data from GEO and got the txt file of sparse matrix. Then I read the file as data frame, normalized it, and exported it as data frame with the code

write.table(as.matrix(GetAssayData(object = Normalized_data, slot = "counts")), 
        sep = '\t', row.names = T, col.names = T, quote = F)

After that I read the Normalized.txt file and convert the data frame to dgCMatrix, ie N_data . Then I tried to construct the SingleCellExperiment object and fit with CellAssign but failed. I faced the error as below:

WARNING:tensorflow:@custom_gradient grad_fn has 'variables' in signature, but no ResourceVariables were used on the forward pass.
Error in py_call_impl(callable, dots$args, dots$keywords) : 
ValueError: Tried to convert 'shape' to a tensor and failed. Error: Cannot convert a partially known TensorShape (1, ?) to a Tensor.

Detailed traceback:
   File "/home/yy/.local/share/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/tensorflow/python/util/", line 153, in error_handler
   raise e.with_traceback(filtered_tb) from None
   File "/home/yy/.local/share/r-miniconda/envs/r-reticulate/lib/python3.7/site-packages/tensorflow/python/framework/", line 534, in _apply_op_helper
   f"Tried to convert '{input_name}' to a tensor and failed. "
In addition: Warning message:
In cellassign(exprs_obj = sce[rownames(as.matrix(marker_new)), ],  :
Genes with no mapping counts are present. Make sure this is expected -- this can be valid input in some cases (e.g. when cell types are overspecified).
scRNA-seq • 173 views

Login before adding your answer.

Traffic: 2040 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6