I am trying to subset my dataset using the "choose_cells" function. However, a new problem emerged: "Error in utils::browseURL(appUrl): 'browser' must be a non-empty character string". I have googled for solutions yet failed to find any feasible ways to work out my problem. To expedite the troubleshooting process, the R script is provided as follows.
--------------------------------------------------------------------------------------------------------------------------------------------------------
rm(list = ls())
setwd("/home/luchao/scATAC/cicero_input/JGI/merge_123/results")
library(cicero)
library(tidyverse)
library(Matrix)
peak_annotation_file <- '/home/luchao/scATAC/cicero_input/JGI/merge_123/peak_annotation.tsv'
df_peakanno <- readr::read_tsv(peak_annotation_file)
sparseMatrix_peakanno <- readr::read_tsv(peak_annotation_file) %>%
dplyr::mutate(peak = factor(peak, levels = peak)) %>%
tidyr::separate_rows(gene, distance, peak_type, sep = ';') %>%
dplyr::filter(!
is.na(gene)) %>%
dplyr::mutate(gene = factor(gene)) %>%
dplyr::group_by(peak, gene) %>%
dplyr::summarise(value = as.integer(n() > 0)) %>%
stats::xtabs(value ~ peak + gene, data = ., sparse = T)
indata <- Matrix::readMM("/home/luchao/scATAC/cicero_input/JGI/merge_123/matrix.mtx")
input_cds <- detect_genes(input_cds)
input_cds <- estimate_size_factors(input_cds)
input_cds <- preprocess_cds(input_cds, method = "LSI")
input_cds <- reduce_dimension(input_cds, reduction_method = 'UMAP',
preprocess_method = "LSI")
plot_cells(input_cds)
umap_coords <- reducedDims(input_cds)$UMAP
cicero_cds <- make_cicero_cds(input_cds, reduced_coordinates = umap_coords)
input_cds <- cluster_cells(input_cds)
input_cds <- learn_graph(input_cds)
cds <- input_cds
get_earliest_principal_node <- function(cds, time_bin="NEC"){
cell_ids <- which(colData(cds)[, "timepoint"] == time_bin)
closest_vertex <-
cds@principal_graph_aux[["UMAP"]]$pr_graph_cell_proj_closest_vertex
closest_vertex <- as.matrix(closest_vertex[colnames(cds), ])
root_pr_nodes <-
igraph::V(principal_graph(cds)[["UMAP"]])$name[as.numeric(names
(which.max(table(closest_vertex[cell_ids,]))))]
root_pr_nodes
}
cds<- order_cells(cds, root_pr_nodes=get_earliest_principal_node(cds))
plot_cells(cds,
color_cells_by = "pseudotime",
label_cell_groups=FALSE,
label_leaves=TRUE,
label_branch_points=TRUE,
graph_label_size=2.0)
plot_cells(cds, color_cells_by = "timepoint", group_label_size=4, graph_label_size=1.5)
pdf("/home/luchao/scATAC/cicero_input/JGI/merge_123/results/pseudotime.pdf",width=7, height=6)
plot_cells(cds, color_cells_by = "pseudotime", group_label_size=4, graph_label_size=1.5)
dev.off()
pdf("/home/luchao/scATAC/cicero_input/JGI/merge_123/results/timepoint.pdf",width=7, height=6)
plot_cells(cds, color_cells_by = "timepoint", group_label_size=4, graph_label_size=1.5)
dev.off()
cds_subset <- choose_cells(cds) #error emerged:Error in utils::browseURL(appUrl): 'browser' must be a non-empty character string