YyLu5 / SECRET

0 stars 1 forks source link

how to create reference dataset like you use in your example? #1

Open ivichadriana opened 2 months ago

ivichadriana commented 2 months ago

Hi! I am trying to use SECRET, but there is an error in the function scRefer to make the cell reference.

The issue seems to be that there is a mismatch between the ct_id values and how the column names are structured in meanCount. Specifically, ct_id contains just the cell type names, while colnames(meanCount) combines the sample ID and cell type names (e.g., "Sample1_mesothelial.cell"). Since grep cannot find an exact match for just the cell type name, it returns no results, making the matrix y empty and causing the error:

Error in apply(y, 1, mean, na.rm = TRUE) : dim(X) must have a positive length

Steps to reproduce:

Create an ExpressionSet

eset <- ExpressionSet(assayData = as.matrix(refdat), phenoData = metadata_adf)

Now run the scRefer function

refdat_final <- scRefer(eset, "cell_types.cell_types", "sample_ids.sample_ids") Error in apply(y, 1, mean, na.rm = TRUE) : dim(X) must have a positive length

Please let me know if I am misunderstanding the methodology. Thank you!

ivichadriana commented 1 month ago

I think the function works under the assumption of multiple samples being used. Can SECRET be used without multiple samples as reference?

YyLu5 commented 1 month ago

Hi Adriana,

The problem is not due to a mismatch in the column name by grep because grep is performing a substring match in the last step. It occurs because you only have one sample, so the grep step is able to find only one column for each cell type. As a result, when you use apply(), your input (y) becomes a numeric vector, which causes the error.

To handle this case with only one sample, you can modify the code by skipping the last step. The final step is intended to calculate the average counts across all samples. However, since you only have one sample, averaging isn't necessary. Therefore, you can simply use scref as your final reference data.

Hope this helps.