Last active
July 27, 2021 18:43
-
-
Save thanhleviet/ad49a1ef95af580007aef6a7862269cf to your computer and use it in GitHub Desktop.
simple R code to generate barcode index for mapping to sample name as biologists sometimes just send Well index rather than the barcode name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Generate barcode indexes for NBD96 kit | |
rm(list = ls()) | |
library(dplyr) | |
library(data.table) | |
index <- sapply(seq(1:6), function(x) paste0(LETTERS[1:8],x)) %>% t() %>% as.vector() | |
bc <- list() | |
letter_length <- 8 | |
number_length <- 6 | |
m <- 0 | |
for (i in seq(1:letter_length)) { | |
for (j in seq(1:number_length)) { | |
m <- m + 1 | |
print(paste0(LETTERS[i],j)) | |
if (i == 1) { | |
n = m | |
} else { | |
n = 12*(i-1) + j | |
} | |
print(paste0("NB",n)) | |
bc[[m]] <- paste0("barcode", n) | |
} | |
} | |
barcode <- unlist(bc) | |
df <- tibble(barcode = barcode, index = index) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment