Skip to content

Commit 586cdb3

Browse files
committed
change priority in CB & UMI name extraction from bam file
1 parent 547e034 commit 586cdb3

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

R/prepareDataFromBam.R

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,18 @@ prepareDataFromBam <- function(bamFile, yieldSize = NULL, verbose = FALSE,
4848

4949
# a checkpoint to parse CB and UMI from the bam file, either from reads or CB/UMI tags.
5050
# currently read name only accepts the format CB_UMI#READNAME (CB & UMI cannot have '_', otherwise parsing fails)
51-
mcols(readGrgList[[counter]])$CB <- case_when(grepl("^[^_]+_[^#]+#", names(readGrgList[[counter]]), perl = TRUE) ~ sub("_.*", "", names(readGrgList[[counter]])),
52-
!is.na(mcols(alignmentInfo)$CB) ~ mcols(alignmentInfo)$CB,
53-
TRUE ~ NA)
51+
mcols(readGrgList[[counter]])$CB <- case_when(
52+
!is.na(mcols(alignmentInfo)$CB) ~ mcols(alignmentInfo)$CB,
53+
grepl("^[^_]+_[^#]+#", names(readGrgList[[counter]]), perl = TRUE) ~ sub("_.*", "", names(readGrgList[[counter]])),
54+
TRUE ~ NA
55+
)
5456

55-
mcols(readGrgList[[counter]])$UMI <- case_when(grepl("^[^_]+_[^#]+#", names(readGrgList[[counter]]), perl = TRUE) ~ sub("^[^_]+_([^#]+)#.*$", "\\1", names(readGrgList[[counter]])),
56-
!is.na(mcols(alignmentInfo)$UB) ~ mcols(alignmentInfo)$UB,
57-
TRUE ~ NA)
57+
mcols(readGrgList[[counter]])$UMI <- case_when(
58+
!is.na(mcols(alignmentInfo)$UB) ~ mcols(alignmentInfo)$UB,
59+
grepl("^[^_]+_[^#]+#", names(readGrgList[[counter]]), perl = TRUE) ~ sub("^[^_]+_([^#]+)#.*$", "\\1", names(readGrgList[[counter]])),
60+
TRUE ~ NA
61+
)
62+
5863
} else{ # if demultiplexed is a string path
5964
mcols(readGrgList[[counter]])$CB <- NA
6065
mcols(readGrgList[[counter]])$UMI <- NA

0 commit comments

Comments
 (0)