Skip to content

Commit

Permalink
fix bug in cell type assignment fct
Browse files Browse the repository at this point in the history
  • Loading branch information
kkang7 committed Apr 26, 2021
1 parent 44502f2 commit 8f8deec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ importFrom(Seurat,RunUMAP)
importFrom(Seurat,ScaleData)
importFrom(dplyr,"%>%")
importFrom(dplyr,group_by)
importFrom(dplyr,top_n)
importFrom(dplyr,slice_max)
importFrom(ggplot2,aes)
importFrom(ggplot2,element_text)
importFrom(ggplot2,geom_point)
Expand Down
12 changes: 7 additions & 5 deletions R/cellTypeAssignSCRNA.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#' @importFrom stats rmultinom rnbinom var
#' @importFrom Seurat CreateSeuratObject NormalizeData FindVariableFeatures ScaleData FindNeighbors FindClusters FindAllMarkers RunUMAP RunTSNE RunPCA
#' @importFrom ggplot2 guide_legend guides aes scale_size_manual scale_shape_manual scale_fill_manual xlab ylab theme ggsave ggplot ggtitle geom_point element_text scale_colour_manual
#' @importFrom dplyr top_n group_by %>%
#' @importFrom dplyr slice_max group_by %>%
#' @importFrom pheatmap pheatmap
#' @importFrom rlang .data
#' @importFrom Matrix colSums
Expand Down Expand Up @@ -315,7 +315,7 @@ cellTypeAssignSCRNA <- function(cdseq_gep = NULL,
## and combine with scRNAseq data ##
###################################################################
# declare variable to avoid R CMD check notes for no visible binding for global variable
avg_logFC <- cluster <- nCount_RNA <- NULL
avg_log2FC <- cluster <- nCount_RNA <- NULL

if(verbose){cat("generating synthetic scRNAseq data using CDSeq estimated GEPs ...\n")}
# generate synthetic scRNAseq
Expand Down Expand Up @@ -397,8 +397,9 @@ cellTypeAssignSCRNA <- function(cdseq_gep = NULL,
if(seurat_find_marker){
if(verbose){cat("Finding markers for clusters...\n")}
cdseq_synth_scRNA_seurat_markers <- Seurat::FindAllMarkers(cdseq_synth_scRNA_seurat, logfc.threshold = seurat_DE_logfc, test.use = seurat_DE_test,verbose = FALSE)
#cdseq_synth_scRNA_seurat_markers %>% dplyr::group_by(cluster) %>% dplyr::top_n(n = 2, wt = avg_logFC)
seurat_top_markers <- cdseq_synth_scRNA_seurat_markers %>% dplyr::group_by(cluster) %>% dplyr::top_n(n = seurat_top_n_markers, wt = avg_logFC)
#cdseq_synth_scRNA_seurat_markers %>% dplyr::group_by(cluster) %>% dplyr::top_n(n = 2, wt = avg_log2FC)
#seurat_top_markers <- cdseq_synth_scRNA_seurat_markers %>% dplyr::group_by(cluster) %>% dplyr::top_n(n = seurat_top_n_markers, wt = avg_log2FC)
seurat_top_markers <- cdseq_synth_scRNA_seurat_markers %>% dplyr::group_by(cluster) %>% dplyr::slice_max(n = seurat_top_n_markers, order_by = avg_log2FC)
}else{
cdseq_synth_scRNA_seurat_markers <- NULL
seurat_top_markers <- NULL
Expand Down Expand Up @@ -535,7 +536,8 @@ cellTypeAssignSCRNA <- function(cdseq_gep = NULL,
}

if(seurat_find_marker){
seurat_top_markers_df <- cdseq_synth_scRNA_seurat_markers_df %>% dplyr::group_by(cluster) %>% dplyr::top_n(n = seurat_top_n_markers, wt = avg_logFC)
#seurat_top_markers_df <- cdseq_synth_scRNA_seurat_markers_df %>% dplyr::group_by(cluster) %>% dplyr::top_n(n = seurat_top_n_markers, wt = avg_log2FC)
seurat_top_markers_df <- cdseq_synth_scRNA_seurat_markers_df %>% dplyr::group_by(cluster) %>% dplyr::slice_max(n = seurat_top_n_markers, order_by = avg_log2FC)
}else{
seurat_top_markers_df <- NULL
}
Expand Down
Binary file modified src/CDSeq.so
Binary file not shown.

0 comments on commit 8f8deec

Please sign in to comment.