Skip to content

Commit fb3c4e1

Browse files
author
Aleksandr Popov
committed
CRAN fixes; bcrdata trimmed to 1000 clonotypes; better compression for datasets
1 parent 61d1b68 commit fb3c4e1

9 files changed

+21
-23
lines changed

R/align_lineage.R

+12-12
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
#' @usage
2424
#'
2525
#' repAlignLineage(.data,
26-
#' .min.lineage.sequences, .prepare_threads, .align_threads, .verbose_output, .nofail)
26+
#' .min_lineage_sequences, .prepare_threads, .align_threads, .verbose_output, .nofail)
2727
#'
2828
#' @param .data The data to be processed. Can be \link{data.frame}, \link{data.table}
2929
#' or a list of these objects.
3030
#'
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
3232
#' cluster (not including germline) is lower than this threshold, this group of sequences
3333
#' will not be aligned and will not be used in next steps of BCR pipeline
3434
#' (will be saved in output table only if .verbose_output parameter is set to TRUE).
@@ -57,7 +57,7 @@
5757
#' * Cluster: cluster name
5858
#' * Germline: germline sequence
5959
#' * 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
6161
#' * Alignment: DNAbin object with alignment or DNAbin object with unaligned sequences (if Aligned=FALSE)
6262
#' * V.length (included if .verbose_output=TRUE): shortest length of V gene part outside of CDR3 region in this
6363
#' group of sequences; longer V genes (including germline) are trimmed to this length before alignment
@@ -70,15 +70,15 @@
7070
#' @examples
7171
#'
7272
#' data(bcrdata)
73-
#' bcr_data <- bcrdata$data %>% top(500) # reduce the dataset to save time on examples
73+
#' bcr_data <- bcrdata$data
7474
#'
7575
#' bcr_data %>%
7676
#' seqCluster(seqDist(bcr_data), .fixed_threshold = 3) %>%
7777
#' repGermline() %>%
78-
#' repAlignLineage(.align_threads = 2, .nofail = TRUE)
78+
#' repAlignLineage(.min_lineage_sequences = 2, .align_threads = 2, .nofail = TRUE)
7979
#' @export repAlignLineage
8080
repAlignLineage <- function(.data,
81-
.min.lineage.sequences = 3,
81+
.min_lineage_sequences = 3,
8282
.prepare_threads = 2,
8383
.align_threads = 4,
8484
.verbose_output = FALSE,
@@ -95,14 +95,14 @@ repAlignLineage <- function(.data,
9595
.data %<>%
9696
apply_to_sample_or_list(
9797
align_single_df,
98-
.min.lineage.sequences = .min.lineage.sequences,
98+
.min_lineage_sequences = .min_lineage_sequences,
9999
.align_threads = .align_threads,
100100
.verbose_output = .verbose_output
101101
)
102102
return(.data)
103103
}
104104

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) {
106106
for (required_column in c("Cluster", "Germline.sequence")) {
107107
if (!(required_column %in% colnames(data))) {
108108
stop(
@@ -118,15 +118,15 @@ align_single_df <- function(data, .min.lineage.sequences, .align_threads, .verbo
118118
plyr::dlply(
119119
.variables = .(get("Cluster"), get("Germline.sequence")),
120120
.fun = prepare_results_row,
121-
.min.lineage.sequences = .min.lineage.sequences,
121+
.min_lineage_sequences = .min_lineage_sequences,
122122
.verbose_output = .verbose_output,
123123
.parallel = TRUE
124124
) %>%
125125
`[`(!is.na(.)) %>%
126126
unname()
127127

128128
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!")
130130
}
131131

132132
# 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
147147

148148
# this function accepts dataframe subset containing rows only for current lineage
149149
# 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) {
151151
cluster_name <- lineage_subset[[1, "Cluster"]]
152152
germline_seq <- lineage_subset[[1, "Germline.sequence"]]
153-
aligned <- nrow(lineage_subset) >= .min.lineage.sequences
153+
aligned <- nrow(lineage_subset) >= .min_lineage_sequences
154154

155155
if (!aligned & !.verbose_output) {
156156
return(NA)

R/germline.R

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#' data(bcrdata)
5151
#'
5252
#' bcrdata$data %>%
53-
#' top(2000) %>% # reduce the dataset to save time on examples
5453
#' repGermline()
5554
#' @export repGermline
5655
repGermline <- function(.data, species = "HomoSapiens", min_nuc_outside_cdr3 = 5, ref_only_first = TRUE) {

R/phylip.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@
4949
#' @examples
5050
#'
5151
#' data(bcrdata)
52-
#' bcr_data <- bcrdata$data %>% top(500) # reduce the dataset to save time on examples
52+
#' bcr_data <- bcrdata$data
5353
#'
5454
#' bcr_data %>%
5555
#' seqCluster(seqDist(bcr_data), .fixed_threshold = 3) %>%
5656
#' repGermline() %>%
57-
#' repAlignLineage(.align_threads = 2, .nofail = TRUE) %>%
57+
#' repAlignLineage(.min_lineage_sequences = 2, .align_threads = 2, .nofail = TRUE) %>%
5858
#' repClonalFamily(.threads = 2, .nofail = TRUE)
5959
#' @export repClonalFamily
6060
repClonalFamily <- function(.data, .threads = parallel::detectCores(), .nofail = FALSE) {

data/bcrdata.rda

-6.25 MB
Binary file not shown.

data/immdata.rda

-56.2 KB
Binary file not shown.

data/scdata.rda

-736 Bytes
Binary file not shown.

man/repAlignLineage.Rd

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/repClonalFamily.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/repGermline.Rd

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)