導(dǎo)入包
library(monocle3)
library(dplyr)
導(dǎo)入10X表達(dá)數(shù)據(jù)
cds <- load_mm_data(mat_path = "./matrix.mtx.gz",
feature_anno_path = "./features.tsv.gz",
cell_anno_path = "./barcodes.tsv.gz")
數(shù)據(jù)預(yù)處理
cds <- preprocess_cds(cds, num_dim = 100)
去批次效應(yīng)
# cds <- align_cds(cds, alignment_group = "batch") # 報(bào)錯(cuò):Error:
cds <- align_cds(cds)
降維和可視化結(jié)果
cds <- reduce_dimension(cds)
?alignment_group:subscript contains invalid names
String specifying a column of colData to use for aligning groups of cells. The column specified must be a factor. Alignment can be used to subtract batch effects in a non-linear way. For correcting continuous effects, use residual_model_formula_str. Default is NULL。可以看到需要我們指定一列來作為比對(duì)組饱须。
?而我通過cellranger獲得的表達(dá)矩陣等三個(gè)數(shù)據(jù)中,不包含批次信息烂琴。因此我才用默認(rèn)設(shè)置。
barcodes.png
features.png
Matrix.png
細(xì)胞聚類
# ln -s /opt/conda/pkgs/libgfortran4-7.5.0-h14aa051_20/lib/libgfortran.so.4.0.0 /usr/lib64/libgfortran.so.4
cds = cluster_cells(cds, resolution=1e-5)
注釋細(xì)胞類型
colData(cds)$assigned_cell_type <- as.character(clusters(cds))
學(xué)習(xí)軌跡圖
cds <- learn_graph(cds)
cds <- order_cells(cds)