Closed patrickjdanaher closed 23 hours ago
Note that github is showing the diff in a weird way.
The old function:
cellxgene2squarexbit <- function(counts, grid, genes, barcodes) {
nreportercycles <- nchar(barcodes[1]) / 2 nbits <- nreportercycles * 4
bitmat = matrix(0, length(setdiff(unique(grid), NA)), nbits) colnames(bitmat) <- paste0("reportercycle", rep(seq_len(nreportercycles), each = 4), c("B", "G", 'Y', "R")) rownames(bitmat) <- setdiff(unique(grid), NA) for (i in seq_len(nreportercycles)) { barcodeposition <- i*2 barcodehere <- substr(barcodes, barcodeposition, barcodeposition) for (col in c("B", "Y", "G", "R")) { tempgenes <- setdiff(genes[barcodehere == col], NA) tempgenes <- intersect(tempgenes, colnames(counts)) temptotal <- Matrix::rowSums(counts[, tempgenes, drop = FALSE]) tempsquaretotal <- by(temptotal, grid, mean) bitmat[names(tempsquaretotal), paste0("reportercycle", i, col)] <- tempsquaretotal } } return(bitmat) }
Replacing some slow inner logic in FOV QC. Confirmed the downstream results are unchanged.