Skip to content

Commit

Permalink
Merge pull request #177 from cole-trapnell-lab/develop
Browse files Browse the repository at this point in the history
Pull for v0.1.3
  • Loading branch information
ctrapnell authored Aug 8, 2019
2 parents e212173 + 30b5bf7 commit 6c31463
Show file tree
Hide file tree
Showing 22 changed files with 616 additions and 95 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ inst/doc
.Rhistory
.RData
.Ruserdata
.DS_store
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ language: r
before_install:
- sudo apt-get install -y libudunits2-dev
- sudo apt-get install -y gdal-bin
- sudo apt-get install -y libgdal1-dev
r:
- bioc-devel
- bioc-release
Expand Down Expand Up @@ -44,6 +45,12 @@ r_binary_packages:
- tibble
- tidyr
- viridis

script:
- |
R CMD build .
travis_wait 20 R CMD check monocle3*tar.gz
after_success:
- Rscript -e 'covr::codecov()'
notifications:
Expand Down
5 changes: 4 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: monocle3
Title: Clustering, differential expression, and trajectory analysis for single-
cell RNA-Seq
Version: 0.1.2
Version: 0.1.3
Authors@R:
person(given = "Hannah",
family = "Pliner",
Expand Down Expand Up @@ -65,6 +65,7 @@ Imports:
RcppParallel,
reshape2 (>= 1.4.3),
reticulate (>= 1.11.1),
rsample (>= 0.0.5),
RhpcBLASctl,
Rtsne (>= 0.15),
S4Vectors,
Expand All @@ -86,3 +87,5 @@ Suggests:
spelling
VignetteBuilder: knitr
Language: en-US
Remotes:
VPetukhov/ggrastr
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export("principal_graph_aux<-")
export(aggregate_gene_expression)
export(choose_cells)
export(choose_graph_segments)
export(clear_cds_slots)
export(cluster_cells)
export(clusters)
export(coefficient_table)
Expand Down
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# monocle3 0.1.3

### Changes
* Added bootstrap bars to plot_percent_cells_positive().
* Added a UMI cutoff for load_cellranger_data().
* Added clear_cds_slots() to clear slots from a cds.
* Added cell_stroke parameter to plot_cells.

### Bug fixes
* Fixed #154, which actually resulted from a problem in how ncenter was calculated for each partition.
* Fixed an issue that prevents plotting cells by pseudotime when root_cells are passed to order_cells().
* Fixed #167 - NAs from plot_genes_by_group.

# monocle3 0.1.2

### Changes
Expand Down
4 changes: 2 additions & 2 deletions R/graph_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ graph_test <- function(cds,

test_res <- tryCatch({
if(method == "Moran_I") {
mt <- my.moran.test(exprs_val, lw, wc, alternative = alternative)
mt <- suppressWarnings(my.moran.test(exprs_val, lw, wc, alternative = alternative))
data.frame(status = 'OK', p_value = mt$p.value,
morans_test_statistic = mt$statistic,
morans_I = mt$estimate[["Moran I statistic"]])
} else if(method == 'Geary_C') {
gt <- my.geary.test(exprs_val, lw, wc, alternative = alternative)
gt <- suppressWarnings(my.geary.test(exprs_val, lw, wc, alternative = alternative))
data.frame(status = 'OK', p_value = gt$p.value,
geary_test_statistic = gt$statistic,
geary_C = gt$estimate[["Geary C statistic"]])
Expand Down
14 changes: 7 additions & 7 deletions R/learn_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -226,27 +226,27 @@ multi_component_RGE <- function(cds,
num_clusters_in_partition <-
length(unique(clusters(cds)[colnames(X_subset)]))
num_cells_in_partition = ncol(X_subset)
ncenter <- cal_ncenter(num_clusters_in_partition, num_cells_in_partition)
if(is.null(ncenter) || ncenter >= ncol(X_subset)) {
ncenter <- ncol(X_subset) - 1
curr_ncenter <- cal_ncenter(num_clusters_in_partition, num_cells_in_partition)
if(is.null(curr_ncenter) || curr_ncenter >= ncol(X_subset)) {
curr_ncenter <- ncol(X_subset) - 1
}
} else {
ncenter <- min(ncol(X_subset) - 1, ncenter)
curr_ncenter <- min(ncol(X_subset) - 1, ncenter)
}
if (verbose)
message(paste("Using", ncenter, "nodes for principal graph"))
message(paste("Using", curr_ncenter, "nodes for principal graph"))

kmean_res <- NULL

centers <- t(X_subset)[seq(1, ncol(X_subset), length.out=ncenter), ,
centers <- t(X_subset)[seq(1, ncol(X_subset), length.out=curr_ncenter), ,
drop = F]
centers <- centers + matrix(stats::rnorm(length(centers), sd = 1e-10),
nrow = nrow(centers)) # add random noise

kmean_res <- tryCatch({
stats::kmeans(t(X_subset), centers=centers, iter.max = 100)
}, error = function(err) {
stats::kmeans(t(X_subset), centers = ncenter, iter.max = 100)
stats::kmeans(t(X_subset), centers = curr_ncenter, iter.max = 100)
})

if (kmean_res$ifault != 0){
Expand Down
6 changes: 5 additions & 1 deletion R/load_cellranger_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ get_genome_in_matrix_path <- function(matrix_path, genome=NULL) {
#' @param pipestance_path Path to the output directory produced by Cell Ranger
#' @param genome The desired genome (e.g., 'hg19' or 'mm10')
#' @param barcode_filtered Load only the cell-containing barcodes
#' @param umi_cutoff Numeric, desired cutoff to include a cell. Default is 100.
#' @return a new cell_data_set object
#' @export
#' @examples
Expand All @@ -41,7 +42,7 @@ get_genome_in_matrix_path <- function(matrix_path, genome=NULL) {
#' gene_bc_matrix <- load_cellranger_data("/home/user/cellranger_output")
#' }
load_cellranger_data <- function(pipestance_path=NULL, genome=NULL,
barcode_filtered=TRUE) {
barcode_filtered=TRUE, umi_cutoff = 100) {
# check for correct directory structure
if (!dir.exists(pipestance_path))
stop("Could not find the pipestance path: '", pipestance_path,"'.
Expand Down Expand Up @@ -132,8 +133,11 @@ load_cellranger_data <- function(pipestance_path=NULL, genome=NULL,
barcodes$V1 = make.unique(barcodes$V1)
colnames(data) = barcodes[,1]
pd = data.frame(barcode=barcodes[,1], row.names=barcodes[,1])
data <- data[,Matrix::colSums(data) > umi_cutoff]
pd <- pd[colnames(data),, drop=FALSE]
gbm <- new_cell_data_set(data,
cell_metadata = pd,
gene_metadata = feature.names)

return(gbm)
}
3 changes: 2 additions & 1 deletion R/order_cells.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ order_cells <- function(cds,
} else if(!is.null(root_cells)){
closest_vertex <- cds@principal_graph_aux[[
reduction_method]]$pr_graph_cell_proj_closest_vertex
root_pr_nodes <- paste("Y_", closest_vertex[root_cells,], sep="")
root_pr_nodes <- unique(paste("Y_", closest_vertex[root_cells,], sep=""))
#principal_graph(cds)[[reduction_method]]
}

cds@principal_graph_aux[[reduction_method]]$root_pr_nodes <- root_pr_nodes
Expand Down
Loading

0 comments on commit 6c31463

Please sign in to comment.