Skip to content

Commit

Permalink
clean up dplyr and reshape2 imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Qile0317 committed Nov 8, 2024
1 parent c6e4682 commit 5c56e07
Show file tree
Hide file tree
Showing 22 changed files with 32 additions and 51 deletions.
3 changes: 1 addition & 2 deletions R/alluvialClones.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
#' [hcl.pals][grDevices::hcl.pals].
#'
#' @importFrom ggalluvial StatStratum geom_flow geom_stratum to_lodes_form geom_alluvium
#' @importFrom dplyr %>% mutate
#'
#'
#' @export
#' @concept SC_Functions
#' @return Alluvial ggplot comparing clone distribution.
Expand Down
1 change: 0 additions & 1 deletion R/clonalCluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#' @importFrom stringdist stringdist
#' @importFrom igraph set_vertex_attr V union
#' @importFrom plyr join
#' @importFrom dplyr bind_rows summarize
#' @importFrom stringr str_replace_all
#' @importFrom rlang %||%
#' @importFrom SummarizedExperiment colData<- colData
Expand Down
2 changes: 1 addition & 1 deletion R/clonalDiversity.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#' @param return.boots export boot strapped values calculated -
#' will automatically exportTable = TRUE.
#' @param skip.boots remove down sampling and boot strapping from the calculation.
#' @importFrom reshape2 melt
#'
#' @importFrom dplyr sample_n
#' @export
#' @concept Visualizing_Clones
Expand Down
3 changes: 1 addition & 2 deletions R/clonalHomeostasis.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
#' environment in addition to the visualization.
#' @param palette Colors to use in visualization - input any
#' [hcl.pals][grDevices::hcl.pals].
#' @importFrom reshape2 melt
#' @importFrom dplyr bind_rows
#'
#' @export
#' @concept Visualizing_Clones
#' @return ggplot of the space occupied by the specific proportion of clones
Expand Down
4 changes: 2 additions & 2 deletions R/clonalNetwork.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
#' @param exportClones Exports a table of clones that are shared
#' across multiple identity groups and ordered by the total number
#' of clone copies.
#' @param palette Colors to use in visualization - input any
#' @param palette Colors to use in visualization - input any
#' [hcl.pals][grDevices::hcl.pals].
#' @importFrom igraph graph_from_data_frame V `V<-`
#' @importFrom dplyr %>% group_by select summarize_all count n across all_of desc
#' @importFrom dplyr summarize_all count across all_of desc
#' @importFrom tidygraph as_tbl_graph activate
#' @importFrom ggraph ggraph geom_edge_bend geom_node_point scale_edge_colour_gradientn circle guide_edge_colourbar
#' @importFrom stats setNames
Expand Down
3 changes: 1 addition & 2 deletions R/clonalOccupy.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
#' environment in addition to the visualization
#' @param palette Colors to use in visualization - input any
#' [hcl.pals][grDevices::hcl.pals]
#' @importFrom dplyr %>% group_by mutate count
#' @importFrom reshape2 melt
#' @importFrom dplyr count
#' @export
#' @concept SC_Functions
#' @return Stacked bar plot of counts of cells by clone frequency group
Expand Down
1 change: 0 additions & 1 deletion R/clonalOverlap.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
#' @param palette Colors to use in visualization - input any
#' [hcl.pals][grDevices::hcl.pals]
#' @importFrom stringr str_to_title
#' @importFrom reshape2 melt
#' @importFrom stats quantile
#' @export
#' @concept Visualizing_Clones
Expand Down
3 changes: 0 additions & 3 deletions R/clonalProportion.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
#' @param palette Colors to use in visualization - input any
#' [hcl.pals][grDevices::hcl.pals]
#'
#' @importFrom reshape2 melt
#' @importFrom dplyr bind_rows n
#'
#' @export
#' @concept Visualizing_Clones
#' @return ggplot of the space occupied by the specific rank of clones
Expand Down
22 changes: 11 additions & 11 deletions R/clonalSizeDistribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,34 @@
#'
#' @examples
#' #Making combined contig data
#' combined <- combineTCR(contig_list,
#' samples = c("P17B", "P17L", "P18B", "P18L",
#' combined <- combineTCR(contig_list,
#' samples = c("P17B", "P17L", "P18B", "P18L",
#' "P19B","P19L", "P20B", "P20L"))
#' clonalSizeDistribution(combined, cloneCall = "strict", method="ward.D2")
#'
#' @param input.data The product of [combineTCR()],
#' @param input.data The product of [combineTCR()],
#' [combineBCR()], or [combineExpression()].
#' @param cloneCall How to call the clone - VDJC gene (**gene**),
#' @param cloneCall How to call the clone - VDJC gene (**gene**),
#' CDR3 nucleotide (**nt**), CDR3 amino acid (**aa**),
#' VDJC gene + CDR3 nucleotide (**strict**) or a custom variable
#' in the data.
#' @param chain indicate if both or a specific chain should be used -
#' VDJC gene + CDR3 nucleotide (**strict**) or a custom variable
#' in the data.
#' @param chain indicate if both or a specific chain should be used -
#' e.g. "both", "TRA", "TRG", "IGH", "IGL".
#' @param threshold Numerical vector containing the thresholds
#' @param threshold Numerical vector containing the thresholds
#' the grid search was performed over.
#' @param method The clustering parameter for the dendrogram.
#' @param group.by The variable to use for grouping.
#' @param exportTable Returns the data frame used for forming the graph.
#' @param palette Colors to use in visualization - input any
#' @param palette Colors to use in visualization - input any
#' [hcl.pals][grDevices::hcl.pals].
#' @importFrom dplyr bind_rows
#'
#' @importFrom ggdendro dendro_data segment label
#' @importFrom stats hclust optim pgamma as.dist
#' @export
#' @concept Visualizing_Clones
#' @return ggplot dendrogram of the clone size distribution
#' @author Hillary Koch

#'
clonalSizeDistribution <- function(input.data,
cloneCall ="strict",
chain = "both",
Expand Down
3 changes: 1 addition & 2 deletions R/combineContigs.R
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ combineTCR <- function(input.data,
#' @param filterNonproductive This option will allow for the removal of
#' nonproductive chains if the variable exists in the contig data. Default
#' is set to TRUE to remove nonproductive contigs.
#' @importFrom dplyr %>% mutate
#' @importFrom assertthat assert_that is.flag
#'
#' @export
#' @concept Loading_and_Processing_Contigs
#' @return List of clones for individual cell barcodes
Expand Down
3 changes: 1 addition & 2 deletions R/combineExpression.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@
#' @param addLabel This will add a label to the frequency header, allowing
#' the user to try multiple group.by variables or recalculate frequencies after
#' subsetting the data.
#' @importFrom dplyr bind_rows %>% summarise left_join mutate select n all_of coalesce
#' @importFrom dplyr left_join all_of coalesce
#' @importFrom rlang %||% sym :=
#' @importFrom SummarizedExperiment colData<- colData
#' @importFrom S4Vectors DataFrame
#' @importFrom assertthat assert_that is.string is.flag
#' @export
#' @concept SC_Functions
#' @return Single-cell object with clone information added to meta data
Expand Down
5 changes: 2 additions & 3 deletions R/exportClones.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#' return a data.frame
#' @param dir directory location to save the csv
#' @param file.name the csv file name
#' @importFrom dplyr bind_rows
#' @importFrom utils write.csv
#' @export
#' @concept Loading_and_Processing_Contigs
Expand Down Expand Up @@ -57,8 +56,8 @@ exportClones <- function(input.data,
write.csv(mat, file = filepath)
}

#' @importFrom dplyr %>% group_by mutate
.TCRmatchExport<- function(input.data) {

.TCRmatchExport <- function(input.data) {

input.data <- .data.wrangle(input.data, NULL, "CTgene", "TRB")

Expand Down
3 changes: 1 addition & 2 deletions R/percentAA.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
#' @param aa.length The maximum length of the CDR3 amino acid sequence.
#' @param exportTable Returns the data frame used for forming the graph.
#' @param palette Colors to use in visualization - input any [hcl.pals][grDevices::hcl.pals].
#' @importFrom reshape2 melt
#' @importFrom dplyr mutate_at %>% mutate_if
#' @importFrom dplyr mutate_at mutate_if
#' @export
#' @concept Summarize_Repertoire
#' @return ggplot of stacked bar graphs of amino acid proportions
Expand Down
1 change: 0 additions & 1 deletion R/percentGenes.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#' @param exportTable Returns the data frame used for forming the graph.
#' @param palette Colors to use in visualization - input any
#' [hcl.pals][grDevices::hcl.pals].
#' @importFrom reshape2 melt
#' @export
#' @concept Summarize_Repertoire
#' @return ggplot of percentage of indicated genes as a heatmap
Expand Down
1 change: 0 additions & 1 deletion R/percentKmer.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#' @param exportTable Returns the data frame used for forming the graph.
#' @param palette Colors to use in visualization - input any
#' [hcl.pals][grDevices::hcl.pals]
#' @importFrom reshape2 melt
#' @importFrom stats mad
#' @export
#' @concept Summarize_Repertoire
Expand Down
1 change: 0 additions & 1 deletion R/percentVJ.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#' @param exportTable Returns the data frame used for forming the graph
#' @param palette Colors to use in visualization - input any
#' [hcl.pals][grDevices::hcl.pals].
#' @importFrom reshape2 melt
#' @export
#' @concept Summarize_Repertoire
#' @return ggplot of percentage of V and J gene pairings as a heatmap
Expand Down
1 change: 0 additions & 1 deletion R/positionalProperty.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#' @param exportTable Returns the data frame used for forming the graph
#' @param palette Colors to use in visualization - input any [hcl.pals][grDevices::hcl.pals]
#' @importFrom stats qt
#' @importFrom dplyr %>% summarise n group_by
#' @export
#' @concept Summarize_Repertoire
#' @return ggplot of line graph of diversity by position
Expand Down
3 changes: 3 additions & 0 deletions R/scRepertoire-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
#' @import ggplot2
#' @importFrom assertthat assert_that is.count is.flag is.string
#' @importFrom stringr str_sort str_split
#' @importFrom dplyr %>% select mutate filter arrange bind_rows group_by n
#' @importFrom dplyr summarise summarize
#' @importFrom reshape2 melt
## usethis namespace: end
NULL
3 changes: 1 addition & 2 deletions R/startracDiversity.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
#' @param group.by The variable in the meta data to group by, often samples.
#' @param exportTable Returns the data frame used for forming the graph.
#' @param palette Colors to use in visualization - input any [hcl.pals][grDevices::hcl.pals].
#' @importFrom reshape2 melt
#' @importFrom dplyr %>% mutate group_by
#'
#' @export
#' @concept SC_Functions
#' @return ggplot object of Startrac diversity metrics
Expand Down
11 changes: 3 additions & 8 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
})
}

#' @importFrom dplyr %>% group_by arrange desc ungroup count mutate
#' @importFrom dplyr desc ungroup count
#' @importFrom rlang ensym !!
.clone.counter <- function(meta,
group.by,
Expand Down Expand Up @@ -164,7 +164,6 @@
df
}

#' @importFrom dplyr bind_rows
#' @keywords internal
.bound.input.return <- function(df) {
if (is_seurat_or_se_object(df)) {
Expand Down Expand Up @@ -264,7 +263,7 @@
}

#Removing extra clones in barcodes with > 2 productive contigs
#' @importFrom dplyr group_by %>% slice_max
#' @importFrom dplyr slice_max
#' @keywords internal
.filteringMulti <- function(x) {
x <- x %>%
Expand All @@ -290,7 +289,7 @@


#Filtering NA contigs out of single-cell expression object
#' @importFrom dplyr %>% transmute
#' @importFrom dplyr transmute
#' @importFrom SingleCellExperiment colData
#' @keywords internal
.filteringNA <- function(sc) {
Expand All @@ -312,7 +311,6 @@

#Organizing list of contigs for visualization
#' @keywords internal
#' @importFrom dplyr %>% group_by n summarise
.parseContigs <- function(df, i, names, cloneCall) {
data <- df[[i]]
data1 <- data %>%
Expand Down Expand Up @@ -371,7 +369,6 @@
# but now also constructs Con.df and runs the parseTCR algorithm on it, all in Rcpp
#' @author Gloria Kraus, Nick Bormann, Nicky de Vrij, Nick Borcherding, Qile Yang
#' @keywords internal
#' @importFrom dplyr %>% arrange
.constructConDfAndParseTCR <- function(data2) {
rcppConstructConDfAndParseTCR(
data2 %>% dplyr::arrange(., chain, cdr3_nt),
Expand Down Expand Up @@ -488,7 +485,6 @@

#Sorting the V/D/J/C gene sequences for T and B cells
#' @importFrom stringr str_c str_replace_na
#' @importFrom dplyr bind_rows mutate %>%
#' @keywords internal
.makeGenes <- function(cellType, data2, chain1, chain2) {
if(cellType %in% c("T")) {
Expand Down Expand Up @@ -575,7 +571,6 @@ is_df_or_list_of_df <- function(x) {
# nucleotide sequence.
#' @importFrom stringdist stringdist
#' @importFrom igraph graph_from_data_frame components graph_from_edgelist
#' @importFrom dplyr bind_rows filter
#' @keywords internal
.lvCompare <- function(dictionary, gene, chain, threshold, exportGraph = FALSE) {
overlap <- NULL
Expand Down
2 changes: 1 addition & 1 deletion R/vizGenes.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#' @param palette Colors to use in visualization - input any
#' [hcl.pals][grDevices::hcl.pals].
#' @importFrom stats sd
#' @importFrom dplyr bind_rows %>% group_by mutate ungroup summarise
#' @importFrom dplyr ungroup
#' @export
#' @concept Visualizing_Clones
#' @return ggplot bar diagram or heatmap of gene usage
Expand Down
4 changes: 2 additions & 2 deletions man/clonalSizeDistribution.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5c56e07

Please sign in to comment.