library(hdf5r)
library(Seurat)
library(dplyr)
library(patchwork)
data_sample <- Read10X_h5("D:\\test\\TISCHdata\\AEL_GSE142213\\AEL_GSE142213_expression.h5") #導(dǎo)入數(shù)據(jù)
pbmc <- CreateSeuratObject(data_sample,project = "test") #后面就可以單細胞處理的標準流程啦
meta <- read_tsv("D:\\test\\TISCHdata\\AEL_GSE142213\\AEL_GSE142213_CellMetainfo_table.tsv")
meta <- as.data.frame(meta)
rownames(meta) <- meta$Cell
pbmc <- AddMetaData(pbmc,meta)
pbmc[["percent.mt"]] <- PercentageFeatureSet(pbmc, pattern = "^MT-")
# Visualize QC metrics as a violin plot
VlnPlot(pbmc, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3)
# FeatureScatter is typically used to visualize feature-feature relationships, but can be used
# for anything calculated by the object, i.e. columns in object metadata, PC scores etc.
pbmc <- subset(pbmc, subset = nFeature_RNA > 200 & nFeature_RNA < 2500 & percent.mt < 5)
pbmc <- NormalizeData(pbmc, normalization.method = "LogNormalize", scale.factor = 10000)
pbmc <- NormalizeData(pbmc)
pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000)
# Identify the 10 most highly variable genes
top10 <- head(VariableFeatures(pbmc), 10)
# plot variable features with and without labels
plot1 <- VariableFeaturePlot(pbmc)
plot2 <- LabelPoints(plot = plot1, points = top10, repel = TRUE)
#plot1 + plot2
all.genes <- rownames(pbmc)
pbmc <- ScaleData(pbmc, features = all.genes)
pbmc <- RunPCA(pbmc, features = VariableFeatures(object = pbmc))
# Examine and visualize PCA results a few different ways
print(pbmc[["pca"]], dims = 1:5, nfeatures = 5)
VizDimLoadings(pbmc, dims = 1:2, reduction = "pca")
DimPlot(pbmc, reduction = "pca")
DimHeatmap(pbmc, dims = 1, cells = 500, balanced = TRUE)
DimHeatmap(pbmc, dims = 1:15, cells = 500, balanced = TRUE)
# NOTE: This process can take a long time for big datasets, comment out for expediency. More
# approximate techniques such as those implemented in ElbowPlot() can be used to reduce
# computation time
pbmc <- JackStraw(pbmc, num.replicate = 100)
pbmc <- ScoreJackStraw(pbmc, dims = 1:20)
JackStrawPlot(pbmc, dims = 1:15)
ElbowPlot(pbmc)
pbmc <- FindNeighbors(pbmc, dims = 1:10)
pbmc <- FindClusters(pbmc, resolution = 0.5)
# If you haven't installed UMAP, you can do so via reticulate::py_install(packages =
# 'umap-learn')
pbmc <- RunUMAP(pbmc, dims = 1:10)
# note that you can set `label = TRUE` or use the LabelClusters function to help label
# individual clusters
DimPlot(pbmc, reduction = "umap")
umap=as.data.frame(pbmc@reductions$umap@cell.embeddings)
#將原始降維信息覆蓋本次降維信息
umap$UMAP_1 <- pbmc@meta.data$UMAP_1
umap$UMAP_2 <- pbmc@meta.data$UMAP_2
pbmc@reductions$umap@cell.embeddings <- as.matrix(umap)
#pbmc@reductions$umap@cell.embeddings = as.matrix(cbind(UMAP_1=pbmc@meta.data$UMAP_1,UMAP_2=pbmc@meta.data$UMAP_2))
saveRDS(pbmc, file = "TISCH.rds")
TISCHdata數(shù)據(jù)預(yù)處理
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門以蕴,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人辛孵,你說我怎么就攤上這事丛肮。” “怎么了魄缚?”我有些...
- 文/不壞的土叔 我叫張陵宝与,是天一觀的道長。 經(jīng)常有香客問我冶匹,道長习劫,這世上最難降的妖魔是什么? 我笑而不...
- 正文 為了忘掉前任嚼隘,我火速辦了婚禮诽里,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘飞蛹。我一直安慰自己谤狡,他們只是感情好灸眼,可當(dāng)我...
- 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著墓懂,像睡著了一般焰宣。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上捕仔,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼瓤逼!你這毒婦竟也來了笼吟?” 一聲冷哼從身側(cè)響起,我...
- 正文 年R本政府宣布宵晚,位于F島的核電站,受9級特大地震影響维雇,放射性物質(zhì)發(fā)生泄漏淤刃。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一谆沃、第九天 我趴在偏房一處隱蔽的房頂上張望钝凶。 院中可真熱鬧仪芒,春花似錦唁影、人聲如沸耕陷。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽哟沫。三九已至,卻和暖如春锌介,著一層夾襖步出監(jiān)牢的瞬間嗜诀,已是汗流浹背。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- Python主要數(shù)據(jù)預(yù)處理函數(shù) 要介紹的Python中的插值温自、數(shù)據(jù)歸一化、主成分分析等與數(shù)據(jù)預(yù)處理相關(guān)的函數(shù)皇钞。 P...
- 預(yù)處理數(shù)預(yù)處理數(shù)據(jù)的方法總結(jié)(使用sklearn-preprocessing) https://blog.csdn...
- 前言:在我的上一份文章中悼泌,介紹到了數(shù)據(jù)清洗的常用方法及其Python實現(xiàn)。這篇文章主要是在數(shù)據(jù)清洗后的特征工程的實...
- 諸如sklearn庫夹界,只能對數(shù)值型數(shù)據(jù)進行訓(xùn)練分析馆里,我們要把非數(shù)值型數(shù)據(jù)轉(zhuǎn)換成數(shù)值型,在這里介紹幾種方法可柿,和大家一...