MarioniLab / miloR

R package implementation of Milo for testing for differential abundance in KNN graphs
https://bioconductor.org/packages/release/bioc/html/miloR.html
GNU General Public License v3.0
339 stars 22 forks source link

Design matrix and nhood counts are not the same dimension #317

Closed nbutyrate closed 1 day ago

nbutyrate commented 5 months ago

Hi I am trying to run MiloR on my data and getting the following error, please help,

here is my workflow sc1 <- as.SingleCellExperiment(Polyp, assay = "RNA")

sc1_milo <- Milo(sc1)

sc1_milo <- buildGraph(sc1_milo, k = 30, d = 30, reduced.dim = "STANDARDPCA")

sc1_milo <- makeNhoods(sc1_milo, prop = 0.1, k = 30, d=30, refined = TRUE, reduced_dims = "STANDARDPCA")

plotNhoodSizeHist(sc1_milo)

sc1_milo <- countCells(sc1_milo, meta.data = as.data.frame(colData(sc1_milo)), sample="SampleNameOnly")

sc1_design <- data.frame(colData(sc1_milo))[,c("SampleNameOnly", "Race1")]

sc1_milo <- calcNhoodDistance(sc1_milo, d=30, reduced.dim = "STANDARDPCA")

da_results <- testNhoods(sc1_milo, design = ~Race1, design.df = sc1_design, reduced.dim = "STANDARDPCA") Error in testNhoods(sc1_milo, design = ~Race1, design.df = sc1_design, : Design matrix (106571) and nhood counts (42) are not the same dimension

MikeDMorgan commented 5 months ago

The design.df data frame needs to be a sample X meta data table, you are giving it a single-cell X meta data table, hence the discordant dimensions.