Rename function arguments to improve readability

This commit is contained in:
coolneng 2021-04-21 22:12:29 +02:00
parent 659f0097d8
commit 81ebd4fbbe
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
1 changed files with 9 additions and 8 deletions

View File

@ -11,22 +11,22 @@ parse_data <- function(file) {
return(list(sequences, vj_segments)) return(list(sequences, vj_segments))
} }
match_id_sequence <- function(names, sequences, id) { match_id_sequence <- function(names, vdj_segments, id) {
matches <- grep(names, pattern = id) matches <- grep(names, pattern = id)
row <- matches[1] row <- matches[1]
return(as.character(sequences[row])) return(as.character(vdj_segments[row]))
} }
get_vj_sequence <- function(sequences, names, vdj_segments) { get_vj_sequence <- function(metadata, names, vdj_segments) {
metadata <- unlist(strsplit(sequences, split = " ")) id_elements <- unlist(strsplit(metadata, split = " "))
v_identifier <- metadata[2] v_identifier <- id_elements[2]
j_identifier <- metadata[3] j_identifier <- id_elements[3]
v_sequence <- match_id_sequence(names, vdj_segments, id = v_identifier) v_sequence <- match_id_sequence(names, vdj_segments, id = v_identifier)
j_sequence <- match_id_sequence(names, vdj_segments, id = j_identifier) j_sequence <- match_id_sequence(names, vdj_segments, id = j_identifier)
return(c(v_sequence, j_sequence)) return(c(v_sequence, j_sequence))
} }
fetch_vj_sequences <- function(vdj_segments, sequences) { fetch_vj_sequences <- function(sequences, vdj_segments) {
vj_sequences <- mclapply(names(sequences), vj_sequences <- mclapply(names(sequences),
names(vdj_segments), names(vdj_segments),
vdj_segments, vdj_segments,
@ -45,8 +45,9 @@ align_sequence <- function(sequence, vdj_segment) {
)) ))
} }
# TODO Extract CDR3
get_hvr_sequences <- function(sequences, vdj_segments) { get_hvr_sequences <- function(sequences, vdj_segments) {
vj_sequences <- fetch_vj_sequences(vdj_segments, sequences) vj_sequences <- fetch_vj_sequences(sequences, vdj_segments)
v_alignment <- parallel::mcmapply(sequences, v_alignment <- parallel::mcmapply(sequences,
vj_sequences[1], vj_sequences[1],
FUN = align_sequence FUN = align_sequence