Compare commits

...

1 Commits

Author SHA1 Message Date
coolneng 66b39485a9
Save vdj alignment sequences to a CSV 2021-03-23 19:35:10 +01:00
2 changed files with 15 additions and 13 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
*.txt *.csv
*.fasta *.fasta
*.fastq *.fastq

View File

@ -19,21 +19,23 @@ amplify_rows <- function(data, column, factor) {
return(rep(data, factor)) return(rep(data, factor))
} }
save_data <- function(data, name) { save_data <- function(data) {
if (name == "sequence") { Biostrings::writeXStringSet(data$sequence, "data/sequence.fasta")
file_name <- paste("data/", name, ".fasta", sep = "") vdj_sequences <- data[-1]
Biostrings::writeXStringSet(data, file_name, format = "fasta") write.csv(vdj_sequences, "data/vdj_alignment.csv", row.names = FALSE)
} else {
file_name <- paste("data/", name, ".txt", sep = "")
cat(data, file = file_name, sep = "\n")
}
} }
process_data <- function(repertoire, sequencing_runs) { 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] data <- repertoire[, columns]
amplified_data <- mapply(data, names(data), sequencing_runs, FUN = amplify_rows) amplified_data <- mapply(data, names(data),
invisible(mapply(amplified_data, names(amplified_data), FUN = save_data)) sequencing_runs,
FUN = amplify_rows
)
save_data(amplified_data)
} }
parse_cli_arguments <- function(args) { parse_cli_arguments <- function(args) {
@ -48,4 +50,4 @@ arguments <- parse_cli_arguments(args)
number_of_sequences <- as.integer(arguments[1]) number_of_sequences <- as.integer(arguments[1])
sequencing_runs <- as.integer(arguments[2]) sequencing_runs <- as.integer(arguments[2])
repertoire <- generate_repertoire(number_of_sequences) repertoire <- generate_repertoire(number_of_sequences)
process_data(repertoire, sequencing_runs) process_data(repertoire, sequencing_runs)