23
23
# ' @usage
24
24
# '
25
25
# ' repAlignLineage(.data,
26
- # ' .min.lineage.sequences , .prepare_threads, .align_threads, .verbose_output, .nofail)
26
+ # ' .min_lineage_sequences , .prepare_threads, .align_threads, .verbose_output, .nofail)
27
27
# '
28
28
# ' @param .data The data to be processed. Can be \link{data.frame}, \link{data.table}
29
29
# ' or a list of these objects.
30
30
# '
31
- # ' @param .min.lineage.sequences If number of sequences in the same clonal lineage and the same
31
+ # ' @param .min_lineage_sequences If number of sequences in the same clonal lineage and the same
32
32
# ' cluster (not including germline) is lower than this threshold, this group of sequences
33
33
# ' will not be aligned and will not be used in next steps of BCR pipeline
34
34
# ' (will be saved in output table only if .verbose_output parameter is set to TRUE).
57
57
# ' * Cluster: cluster name
58
58
# ' * Germline: germline sequence
59
59
# ' * Aligned (included if .verbose_output=TRUE): FALSE if this group of sequences was not aligned with lineage
60
- # ' (.min.lineage.sequences is below the threshold); TRUE if it was aligned
60
+ # ' (.min_lineage_sequences is below the threshold); TRUE if it was aligned
61
61
# ' * Alignment: DNAbin object with alignment or DNAbin object with unaligned sequences (if Aligned=FALSE)
62
62
# ' * V.length (included if .verbose_output=TRUE): shortest length of V gene part outside of CDR3 region in this
63
63
# ' group of sequences; longer V genes (including germline) are trimmed to this length before alignment
70
70
# ' @examples
71
71
# '
72
72
# ' data(bcrdata)
73
- # ' bcr_data <- bcrdata$data %>% top(500) # reduce the dataset to save time on examples
73
+ # ' bcr_data <- bcrdata$data
74
74
# '
75
75
# ' bcr_data %>%
76
76
# ' seqCluster(seqDist(bcr_data), .fixed_threshold = 3) %>%
77
77
# ' repGermline() %>%
78
- # ' repAlignLineage(.align_threads = 2, .nofail = TRUE)
78
+ # ' repAlignLineage(.min_lineage_sequences = 2, . align_threads = 2, .nofail = TRUE)
79
79
# ' @export repAlignLineage
80
80
repAlignLineage <- function (.data ,
81
- .min.lineage.sequences = 3 ,
81
+ .min_lineage_sequences = 3 ,
82
82
.prepare_threads = 2 ,
83
83
.align_threads = 4 ,
84
84
.verbose_output = FALSE ,
@@ -95,14 +95,14 @@ repAlignLineage <- function(.data,
95
95
.data %<> %
96
96
apply_to_sample_or_list(
97
97
align_single_df ,
98
- .min.lineage.sequences = .min.lineage.sequences ,
98
+ .min_lineage_sequences = .min_lineage_sequences ,
99
99
.align_threads = .align_threads ,
100
100
.verbose_output = .verbose_output
101
101
)
102
102
return (.data )
103
103
}
104
104
105
- align_single_df <- function (data , .min.lineage.sequences , .align_threads , .verbose_output ) {
105
+ align_single_df <- function (data , .min_lineage_sequences , .align_threads , .verbose_output ) {
106
106
for (required_column in c(" Cluster" , " Germline.sequence" )) {
107
107
if (! (required_column %in% colnames(data ))) {
108
108
stop(
@@ -118,15 +118,15 @@ align_single_df <- function(data, .min.lineage.sequences, .align_threads, .verbo
118
118
plyr :: dlply(
119
119
.variables = .(get(" Cluster" ), get(" Germline.sequence" )),
120
120
.fun = prepare_results_row ,
121
- .min.lineage.sequences = .min.lineage.sequences ,
121
+ .min_lineage_sequences = .min_lineage_sequences ,
122
122
.verbose_output = .verbose_output ,
123
123
.parallel = TRUE
124
124
) %> %
125
125
`[`(! is.na(. )) %> %
126
126
unname()
127
127
128
128
if (length(results ) == 0 ) {
129
- stop(" There are no lineages containing at least " , .min.lineage.sequences , " sequences!" )
129
+ stop(" There are no lineages containing at least " , .min_lineage_sequences , " sequences!" )
130
130
}
131
131
132
132
# only required columns are passed to alignment function to reduce consumed memory
@@ -147,10 +147,10 @@ align_single_df <- function(data, .min.lineage.sequences, .align_threads, .verbo
147
147
148
148
# this function accepts dataframe subset containing rows only for current lineage
149
149
# and returns named list containing 1 row for results dataframe
150
- prepare_results_row <- function (lineage_subset , .min.lineage.sequences , .verbose_output ) {
150
+ prepare_results_row <- function (lineage_subset , .min_lineage_sequences , .verbose_output ) {
151
151
cluster_name <- lineage_subset [[1 , " Cluster" ]]
152
152
germline_seq <- lineage_subset [[1 , " Germline.sequence" ]]
153
- aligned <- nrow(lineage_subset ) > = .min.lineage.sequences
153
+ aligned <- nrow(lineage_subset ) > = .min_lineage_sequences
154
154
155
155
if (! aligned & ! .verbose_output ) {
156
156
return (NA )
0 commit comments