Compare commits

...

2 Commits

Author SHA1 Message Date
coolneng eee25f7eb3
Update gitignore 2021-03-23 19:34:46 +01:00
coolneng f6ad675cc4
Save vdj alignment sequences to a CSV 2021-03-23 19:33:32 +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) {