Document the repertoire script
This commit is contained in:
parent
9e8beefd38
commit
f4b7a41599
|
@ -1,6 +1,10 @@
|
||||||
library(immuneSIM)
|
library(immuneSIM)
|
||||||
library(Biostrings)
|
library(Biostrings)
|
||||||
|
|
||||||
|
#' Generate the beta chain of a human T-cell receptor (TCR)
|
||||||
|
#'
|
||||||
|
#' @param number_of_sequences Number of different sequences to generate
|
||||||
|
#' @return A \code{data.frame} with the sequences, V and J genes and CDR3
|
||||||
generate_repertoire <- function(number_of_sequences) {
|
generate_repertoire <- function(number_of_sequences) {
|
||||||
return(immuneSIM(
|
return(immuneSIM(
|
||||||
number_of_seqs = number_of_sequences,
|
number_of_seqs = number_of_sequences,
|
||||||
|
@ -10,6 +14,9 @@ generate_repertoire <- function(number_of_sequences) {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#' Saves the sequences and CDR3 to FASTQ files
|
||||||
|
#'
|
||||||
|
#' @param data A \code{data.frame} with the preprocessed TCR sequences and CDR3
|
||||||
save_data <- function(data) {
|
save_data <- function(data) {
|
||||||
Biostrings::writeXStringSet(data$sequence,
|
Biostrings::writeXStringSet(data$sequence,
|
||||||
"data/sequence.fastq",
|
"data/sequence.fastq",
|
||||||
|
@ -18,6 +25,11 @@ save_data <- function(data) {
|
||||||
Biostrings::writeXStringSet(data$junction, "data/HVR.fastq", format = "fastq")
|
Biostrings::writeXStringSet(data$junction, "data/HVR.fastq", format = "fastq")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#' Applies the reverse complement and amplifies the number of sequences
|
||||||
|
#'
|
||||||
|
#' @param data A \code{data.frame} containing the TCR sequences and CDR3
|
||||||
|
#' @param reads Number of times to amplify each sequence
|
||||||
|
#' @return A \code{data.frame} with reverse complement sequences and VJ metadata
|
||||||
process_data <- function(data, reads) {
|
process_data <- function(data, reads) {
|
||||||
dna_sequence <- Biostrings::DNAStringSet(data$sequence)
|
dna_sequence <- Biostrings::DNAStringSet(data$sequence)
|
||||||
data$sequence <- Biostrings::reverseComplement(dna_sequence)
|
data$sequence <- Biostrings::reverseComplement(dna_sequence)
|
||||||
|
@ -28,6 +40,9 @@ process_data <- function(data, reads) {
|
||||||
return(amplified_data)
|
return(amplified_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#' Checks the number of command line arguments and captures them
|
||||||
|
#'
|
||||||
|
#' @return A \code{vector} containing the command line arguments
|
||||||
parse_cli_arguments <- function() {
|
parse_cli_arguments <- function() {
|
||||||
args <- commandArgs(trailingOnly = TRUE)
|
args <- commandArgs(trailingOnly = TRUE)
|
||||||
if (length(args) != 2) {
|
if (length(args) != 2) {
|
||||||
|
|
Loading…
Reference in New Issue