From 21e3b54aaaf434c33142f941b2169f3a612c9727 Mon Sep 17 00:00:00 2001 From: theHumanBorch Date: Tue, 8 Oct 2024 12:36:10 -0500 Subject: [PATCH] update clonalLength() Fix issue with single chain per #412 Removed code that was pre-data.wrangle() internal function --- DESCRIPTION | 2 +- NEWS.md | 6 ++++++ R/clonalLength.R | 13 +------------ R/utils.R | 11 +++++++---- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fa2d7193..e4453f48 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: scRepertoire Title: A toolkit for single-cell immune receptor profiling -Version: 2.0.7 +Version: 2.0.8 Authors@R: c( person(given = "Nick", family = "Borcherding", role = c("aut", "cre"), email = "ncborch@gmail.com"), person(given = "Qile", family = "Yang", role = c("aut"), email = "qile.yang@berkeley.edu"), diff --git a/NEWS.md b/NEWS.md index bcf67b14..e262e8d7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# scRepertoire VERSION 2.0.8 + +## UNDERLYING CHANGES +* Fixed issue with single chain output for ```clonalLength()``` +* Removed unnecessary code remnant in ```clonalLength()``` + # scRepertoire VERSION 2.0.7 ## UNDERLYING CHANGES diff --git a/R/clonalLength.R b/R/clonalLength.R index b5314279..a1817c3b 100644 --- a/R/clonalLength.R +++ b/R/clonalLength.R @@ -61,20 +61,9 @@ clonalLength <- function(input.data, CDR3 sequence to analyze by using `cloneCall`") } - #Identifying and assigning chains - chain.pos <- which(colnames(input.data[[1]]) == "cdr3_aa1")-1 - c1 <- na.omit(unique(substr(input.data[[1]][seq_len(10),chain.pos], 1,3))) - c1 <- c1[c1 != "NA."] - c1 <- c1[c1 != "NA"] - - c2 <- switch(c1, - "TRA" = "TRB", - "IGH" = "IGL", - "TRG" = "TRD") - #Calculating Length Con.df <- NULL - Con.df <- .lengthDF(input.data, cloneCall, chain, group.by, c1, c2) + Con.df <- .lengthDF(input.data, cloneCall, chain, group.by) names <- names(input.data) diff --git a/R/utils.R b/R/utils.R index a6a86185..75bd06f7 100644 --- a/R/utils.R +++ b/R/utils.R @@ -427,7 +427,7 @@ #Producing a data frame to visualize for lengthContig() #' @keywords internal #' @importFrom stringr str_remove_all -.lengthDF <- function(df, cloneCall, chain, group, c1, c2){ +.lengthDF <- function(df, cloneCall, chain, group){ Con.df <- NULL names <- names(df) if (identical(chain, "both")) { @@ -456,14 +456,17 @@ chain1 <- nchar(val1) if (!is.null(group)) { cols1 <- df[[x]][,group] - data1 <- data.frame(chain1, val1, names[x], c1, cols1) + data1 <- data.frame(chain1, val1, names[x], chain, cols1) colnames(data1)<-c("length","CT","values","chain",group) }else if (is.null(group)){ - data1 <- data.frame(chain1, val1, names[x], c1) + data1 <- data.frame(chain1, val1, names[x], chain) colnames(data1) <- c("length", "CT", "values", "chain") + } data <- na.omit(data1) data <- subset(data, CT != "NA" & CT != "") - Con.df<- rbind.data.frame(Con.df, data) }} + Con.df<- rbind.data.frame(Con.df, data) + + } } return(Con.df) }