Save vdj alignment sequences to a CSV
This commit is contained in:
parent
97b8914cd5
commit
f6ad675cc4
|
@ -19,21 +19,23 @@ amplify_rows <- function(data, column, factor) {
|
|||
return(rep(data, factor))
|
||||
}
|
||||
|
||||
save_data <- function(data, name) {
|
||||
if (name == "sequence") {
|
||||
file_name <- paste("data/", name, ".fasta", sep = "")
|
||||
Biostrings::writeXStringSet(data, file_name, format = "fasta")
|
||||
} else {
|
||||
file_name <- paste("data/", name, ".txt", sep = "")
|
||||
cat(data, file = file_name, sep = "\n")
|
||||
}
|
||||
save_data <- function(data) {
|
||||
Biostrings::writeXStringSet(data$sequence, "data/sequence.fasta")
|
||||
vdj_sequences <- data[-1]
|
||||
write.csv(vdj_sequences, "data/vdj_alignment.csv", row.names = FALSE)
|
||||
}
|
||||
|
||||
process_data <- function(repertoire, sequencing_runs) {
|
||||
columns <- c("sequence", "v_call", "j_call")
|
||||
columns <- c(
|
||||
"sequence", "v_sequence_alignment",
|
||||
"d_sequence_alignment", "j_sequence_alignment"
|
||||
)
|
||||
data <- repertoire[, columns]
|
||||
amplified_data <- mapply(data, names(data), sequencing_runs, FUN = amplify_rows)
|
||||
invisible(mapply(amplified_data, names(amplified_data), FUN = save_data))
|
||||
amplified_data <- mapply(data, names(data),
|
||||
sequencing_runs,
|
||||
FUN = amplify_rows
|
||||
)
|
||||
save_data(amplified_data)
|
||||
}
|
||||
|
||||
parse_cli_arguments <- function(args) {
|
||||
|
|
Loading…
Reference in New Issue