10x轉錄組數據進行RNA velocity分析

2021-02-20 東林的扯淡小屋

首先看看需要什麼樣的命令才能有loom文件:

Usage: velocyto run10x [OPTIONS] SAMPLEFOLDER GTFFILE

  Runs the velocity analysis for a Chromium 10X Sample

  10XSAMPLEFOLDER specifies the cellranger sample folder

  GTFFILE genome annotation file

Options:

  -s, --metadatatable FILE        Table containing metadata of the various samples (csv fortmated rows are samples and cols are entries)

  -m, --mask FILE                 .gtf file containing intervals to mask

  -l, --logic TEXT                The logic to use for the filtering (default: Default)

  -M, --multimap                  Consider not unique mappings (not reccomended)

  -@, --samtools-threads INTEGER  The number of threads to use to sort the bam by cellID file using samtools

  --samtools-memory INTEGER       The number of MB used for every thread by samtools to sort the bam file

  -t, --dtype TEXT                The dtype of the loom file layers - if more than 6000 molecules/reads per gene per cell are expected set uint32 to avoid truncation (default run_10x: uint16)

  -d, --dump TEXT                 For debugging purposes only: it will dump a molecular mapping report to hdf5. --dump N, saves a cell every N cells. If p is prepended a more complete (but huge) pickle report is printed (default: 0)

  -v, --verbose                   Set the vebosity level: -v (only warinings) -vv (warinings and info) -vvv (warinings, info and debug)

  --help                          Show this message and exit.

CLI Usage Guide — velocyto 0.17.16 documentation

http://velocyto.org/velocyto.py/tutorial/cli.html

我一開始還以為自己成功跑上了,但是很快就出錯了:

通過搜索,發現可能是自己下載文件出了問題:

Need preparation data to run velocyto: samtools version, bam file, repeat_msk.gtf · Issue #112 · velocyto-team/velocyto.py

https://github.com/velocyto-team/velocyto.py/issues/112

Table Browser

https://genome.ucsc.edu/cgi-bin/hgTables?hgsid=611454127_NtvlaW6xBSIRYJEBI0iRDEWisITa&clade=mammal&org=Mouse&db=mm10&hgta_group=allTracks&hgta_track=xenoRefGene&hgta_table=0&hgta_regionType=genome&position=chr12%3A56%2C694%2C976-56%2C714%2C605&hgta_outputType=gff&hgta_outFileName=hg38_repeats_repeatMasker_allTracks.gtf

下載之後解壓到伺服器,重新跑,就成功了喲!

幾個小時之後還是沒有報錯!

這是個好兆頭~。

velocyto run10x -m /data/yudonglin/velocity/mm10_rmsk.gtf /data/yudonglin/singlecell/ABFC20190816-04-分析結果/NoPro /data/yudonglin/velocity/refdata-gex-mm10-2020-A/genes/genes.gtf

最終得到loom文件!

然後又遇到問題:

export OPENBLAS_NUM_THREADS=1

「生信Debug」OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable_xuzhougeng blog-CSDN博客

https://blog.csdn.net/u012110870/article/details/106115577

最終成功!

> library(velocyto.R)Loading required package: Matrix> library(pagoda2)Loading required package: igraph
Attaching package: 『igraph』
The following objects are masked from 『package:stats』:
decompose, spectrum
The following object is masked from 『package:base』:
union

Attaching package: 『pagoda2』
The following object is masked from 『package:velocyto.R』:
armaCor
> ldat <- read.loom.matrices("/data/yudonglin/singlecell/ABFC20190816-04-分析結果/NoPro/velocyto/NoPro.loom")reading loom file via hdf5r...
> emat <- ldat$spliced> hist(log10(colSums(emat)),col='wheat',xlab='cell size')> > > emat <- emat[,colSums(emat)>=1e3] > emat <- emat[!duplicated(rownames(emat)),]> > r <- Pagoda2$new(emat, modelType = "plain", trim = 10, log.scale = TRUE)8158cells,32245genes; normalizing ... using plain model winsorizing ... log scale ... done.
> r$adjustVariance(plot = TRUE, do.par = TRUE, gam.k = 10)calculating variance fit ... using gam 2271overdispersed genes ...2271persisting ... done.
> r$calculatePcaReduction(nPcs = 100, n.odgenes = 3e3, maxit = 300)running PCA using 3000 OD genes .... done
> r$makeKnnGraph(k = 30, type = "PCA", center = TRUE,distance = "cosine")creating space of type angular doneadding data ... donebuilding index ... donequerying ... done> r$getKnnClusters(method = multilevel.community, type = "PCA",name = "multilevel")w.legend = FALSE, mark.clusters = TRUE, min.group.size = 10, shuffle.colors = FALSE, mark.cluster.cex = 1, alpha = 0.3, main = "cell clusters")r$plotEmbedding(type = "PCA", embeddingType = "tSNE", colors = r$depth, main = "depth")> r$getEmbedding(type = "PCA", embeddingType = "tSNE",+ perplexity = 50,verbose = FALSE)calculating distance ... pearson ...
running tSNE using56cores:
> r$plotEmbedding(type = "PCA", embeddingType = "tSNE",+ show.legend = FALSE, mark.clusters = TRUE,+ min.group.size = 10, shuffle.colors = FALSE,+ mark.cluster.cex = 1, alpha = 0.3, main = "cell clusters")Warning message:Ignoring unknown parameters: mark.clusters, min.group.size, mark.cluster.cex, main > r$plotEmbedding(type = "PCA", embeddingType = "tSNE", colors = r$depth, main = "depth")> emat <- ldat$spliced> nmat <- ldat$unspliced> emat <- emat[,rownames(r$counts)]nes.by.cluster.expression(emat, cluster.label, min.max.cluster.average = 0.2)nmat <- filter.genes.by.cluster.expression(nmat, cluster.label, min.max.cluster.average = 0.05)length(intersect(rownames(emat), rownames(nmat)))> nmat <- nmat[,rownames(r$counts)]> > cluster.label <- r$clusters$PCA$multilevel > emb <- r$embeddings$PCA$tSNE> cell.dist <- as.dist(1-armaCor(t(r$reductions$PCA)))> emat <- filter.genes.by.cluster.expression(emat, cluster.label,+ min.max.cluster.average = 0.2)> nmat <- filter.genes.by.cluster.expression(nmat, cluster.label,+ min.max.cluster.average = 0.05)> length(intersect(rownames(emat), rownames(nmat)))[1] 7526> fit.quantile <- 0.02> rvel.cd <- gene.relative.velocity.estimates(emat, nmat,deltaT = 1,+ kCells = 25, cell.dist = cell.dist,+ fit.quantile = fit.quantile)calculating cell knn ... donecalculating convolved matrices ... donefitting gamma coefficients ... done. succesfful fit for 7526 genesfiltered out 15 out of 7526 genes due to low nmat-emat correlationfiltered out 562 out of 7511 genes due to low nmat-emat slopecalculating RNA velocity shift ... donecalculating extrapolated cell state ... done> show.velocity.on.embedding.cor(emb,rvel.cd,n=300,scale='sqrt',cell.colors=ac(cell.colors,alpha=0.5),cex=0.8,arrow.scale=5,show.grid.flow=TRUE,min.grid.cell.mass=0.5,grid.n=40,arrow.lwd=1,do.par=F,cell.border.alpha = 0.1)Error in as.character(col) %in% "0" : object 'cell.colors' not found> cell.colors <- sccore::fac2col(cluster.label)> show.velocity.on.embedding.cor(emb, rvel.cd, n = 200, scale = 'sqrt',+ cell.colors = ac(cell.colors, alpha = 0.5),+ cex = 0.8, arrow.scale = 3, show.grid.flow = TRUE,+ min.grid.cell.mass = 0.5, grid.n = 40,+ arrow.lwd = 1,do.par = TRUE, cell.border.alpha = 0.1)delta projections ... sqrt knn ... transition probs ... donecalculating arrows ... donegrid estimates ... grid.sd= 1.327798 min.arrow.size= 0.02655596 max.grid.arrow.length= 0.0536128 done> > gene.relative.velocity.estimates(emat, nmat, deltaT = 1, kCells = 25,+ kGenes = 1, fit.quantile = fit.quantile,+ cell.emb = emb, cell.colors = cell.colors,+ cell.dist = cell.dist, show.gene = "GAPDH",+ old.fit = rvel.cd, do.par = TRUE)Error in gene.relative.velocity.estimates(emat, nmat, deltaT = 1, kCells = 25, : gene GAPDH is not present in the filtered expression matrices> dev.off()null device 1 > gene.relative.velocity.estimates(emat, nmat, deltaT = 1, kCells = 25,+ kGenes = 1, fit.quantile = fit.quantile,+ cell.emb = emb, cell.colors = cell.colors,+ cell.dist = cell.dist, show.gene = "Gapdh",+ old.fit = rvel.cd, do.par = TRUE)calculating convolved matrices ... done[1] 1> dev.off()null device 1 >

成功!歐耶!

重複一下結果還不一樣耶,這個有點坑爹哇!

接下來就是如何把這個結果展示在我們自己的tsne圖或者umap圖上。

在原有的UMAP上標註RNA velocity - 雲+社區 - 騰訊雲

https://cloud.tencent.com/developer/article/1620345

當然,還是不出所料有問題,然後就去解決。

(重點是讓行名即barcode一致)

library(velocyto.R)library(pagoda2)YDL<- readRDS("YDL_NONPRO.rds")ldat <- read.loom.matrices(file = "/data/yudonglin/singlecell/ABFC20190816-04-分析結果/NoPro/velocyto/NoPro.loom")emat <- ldat$splicednmat <- ldat$unsplicedseurat.object<-YDLemb <- seurat.object@reductions$umap@cell.embeddingscell.dist <- as.dist(1-armaCor(t(seurat.object@reductions$umap@cell.embeddings)))head(colnames(emat))head(colnames(nmat))colnames(emat) <- paste(substring(colnames(emat),7,22),"-1",sep="")colnames(nmat) <- paste(substring(colnames(nmat),7,22),"-1",sep="")head(colnames(emat))head(colnames(nmat))fit.quantile <- 0.02
rvel.cd <- gene.relative.velocity.estimates(emat,nmat,deltaT=2, kCells=10, cell.dist=cell.dist, fit.quantile=fit.quantile, n.cores=24)library("Seurat")library("ggplot2")
gg <- UMAPPlot(seurat.object)ggplot_build(gg)$datacolors <- as.list(ggplot_build(gg)$data[[1]]$colour)names(colors) <- rownames(emb)p1 <- show.velocity.on.embedding.cor(emb,rvel.cd,n=30,scale='sqrt', cell.colors=ac(colors,alpha=0.5), cex=0.8,arrow.scale=2,show.grid.flow=T, min.grid.cell.mass=1.0,grid.n=50,arrow.lwd=1, do.par=F,cell.border.alpha = 0.1, n.cores=24,main="RNA Velocity")

原來的umap圖如下:

相關焦點

  • 細胞分化高級玩法——RNA velocity 分析,你 get 了嗎?
    研究證明,基於現有的多種測序平臺 (SMART-seq2,STRT / C1,inDrop 和 10x Genomics Chromium) 測得的單細胞轉錄組數據中,均可檢測到包含未剪接的內含子序列的 reads,表明在單細胞轉錄組測序數據中可以檢測到類似的信號,可以揭示整個轉錄組在動態過程中變化的速率和方向。
  • 10x單細胞免疫組庫VDJ數據分析就看它
    2015年,10x Genomics發布了基於微流控和油滴包裹技術的Chromium單細胞系統平臺,可實現高通量的單細胞轉錄組和單細胞V(D)J測序。不但可以將TCR/BCR雙鏈完美匹配,而且可以細化到單細胞水平,同時獲得表達譜信息。目前該技術也是研究單細胞免疫組庫應用最廣泛的技術,那麼10x 單細胞免疫數據該如何分析?分析結果又有哪些呢?今天小編帶大家來聊聊單細胞免疫組庫測序數據分析那些事。
  • 全新升級|安諾發布新一代10x Genomics單細胞轉錄組結題報告
    10x Genomics單細胞轉錄組測序在細胞異質性研究中具有顯著價值,目前已廣泛應用於細胞圖譜構建、細胞異質性研究、發育及分化、免疫反應、新型細胞發現等領域。為幫助客戶獲得更多的有效信息,安諾基因將10x Genomics單細胞轉錄組結題報告整體升級,新一代結題報告含有更加豐富的內容:多樣本合併分析、擬時間序列分析(Pseudotime分析)納入標準分析新增細胞注釋、差異基因WikiPathway富集和GSEA分析標準分析費用降價1,000元+
  • 10x Genomics空間轉錄組學中文視頻精彩呈現
    空間轉錄組學是指從一個完整的組織樣本中產生全部的轉錄組數據,從而能夠定位和區分哪些基因在組織內是活躍的,為研究和診斷提供寶貴的見解
  • 單細胞轉錄組高級分析四:scRNA數據推斷CNV
    上期專題我們介紹了單細胞轉錄組數據的基礎分析
  • 神助攻帶你「撩」起單細胞轉錄組
    帶著無比喜悅,無比激動的心情,小編用幾個數字給您炫一下10x Genomics這一神助攻應用於單細胞轉錄組測序的六大優勢!本研究應用10x GemCode™平臺對29個細胞系及RNA樣本,共250,000個單細胞,及68,000個外周血單個核細胞(PBMC)進行3』單細胞轉錄組測序分析。1.
  • 各種坑,各種填 | RNA velocity of single cells
    圖片來源:Nature那麼如何利用單細胞數據進行該分析呢?今天我們就來聊一下 10X genomic 數據的分析流程。Cellranger 預處理10X genomic 數據10X genomic 數據的預處理是用 cellranger 軟體完成的,完成這一步之後會得到一個包含所有分析結果的文件夾,而這個文件夾就是你要做 RNA velocity 的基礎。
  • 轉錄組研究新利器:ONT直接RNA測序,鹼基修飾、轉錄異構體一網打盡!
    長讀長cDNA測序方法能夠產生跨越整個異構體的全長轉錄本序列,從而去除或大幅度減少模糊定位,並改進差異異構表達的分析結果。然而,以上方法依賴於cDNA的合成及PCR擴增,去除了天然RNA的鹼基修飾信息,並且只能粗略地估計多聚腺苷酸(poly(A))尾長。
  • 一個超簡單的轉錄組項目全過程--iMac+RNA-Seq(四)featureCounts
    前期文章一個超簡單的轉錄組項目全過程--iMac+RNA-Seq(一)一個超簡單的轉錄組項目全過程-
  • 空間轉錄組研究將對基因測序領域帶來的三大影響及作用
    我們現在已經看到了單細胞測序技術逐漸從完成概念驗證進入臨床場景,而空間轉錄組學很有可能會成為單細胞測序之後,又一個閃閃發光的測序技術外延領域。 空間轉錄組測序有什麼作用? 通常進行的轉錄組學測序過程,是將一群細胞的RNA提取建庫進行測序。
  • 10x Genomics單細胞轉錄組+ISO-seq深入了解流感病毒感染細胞間異質性
    而現有的流式細胞和螢光檢測技術只能測定蛋白水平,單細胞轉錄組技術只能測定短片段轉錄本的豐度。這些技術均不能可靠地揭示感染細胞的病毒粒子是否具有某種特殊突變而不足以確定病毒遺傳多樣性如何在感染期間促進細胞間異質性從而激活先天免疫。
  • 空間轉錄組測序或將成下一個熱點?這家公司已斥巨資壟斷行業
    通常進行的轉錄組學測序過程,是將一群細胞的RNA提取建庫進行測序。這種方法在細胞成分單一的情況下有比較高的指導意義,但是當細胞成分複雜,比如檢測組織樣本時,RNA建庫的過程導致所有細胞的RNA被混在一起檢測,互相干擾,最終的檢測結果只能輸出整個細胞群的平均值,數據的精細度大幅降低。
  • 博奧晶典空間轉錄組測序技術獲認證
    博奧晶典空間轉錄組測序技術獲認證 2020-09-
  • 空間轉錄組測序或將成下一個熱點?10x Genomics已斥巨資壟斷行業
    我們現在已經看到了單細胞測序技術逐漸從完成概念驗證進入臨床場景,而空間轉錄組學很有可能會成為單細胞測序之後,又一個閃閃發光的測序技術外延領域。空間轉錄組測序有什麼作用?通常進行的轉錄組學測序過程,是將一群細胞的RNA提取建庫進行測序。
  • 基因測序(視頻+課件),輕鬆學會數據的處理和分析
    比如,什麼是基因組,什麼是轉錄組,什麼是蛋白組,什麼是染色體,什麼是基因,什麼是基因重組,什麼是進化/演化,什麼是表觀遺傳,什麼是變異,變異類型有哪些,NGS技術是什麼,測序儀的工作原理是什麼,DNA是如何被測出來的等這些東西。因為,你只有真正了解數據是如何來的,才能更好地明白數據該如何處理和分析,以及如何才能有效地挖掘出它背後隱含的生物知識。
  • 全長轉錄組揭示高加索三葉草根莖發育階段分析
    然而,對於高加索三葉草根莖系統發育的轉錄後機制尚未得到全面的研究。此外,該物種的參考基因組尚未發表,這限制了對該植物許多重要生物學過程的進一步探索。採用PacBio測序和Illumina測序技術,對白三葉根莖中主根(T1)、水平根莖(T2)、主根膨大(T3)、根莖芽(T4)和根莖芽尖(T5) 5個組織中差異表達基因(DEGs)進行了鑑定。
  • 靶向單細胞多組學方法,可在低深度下同時檢測蛋白表達和低豐度轉錄組
    研究團隊將該方法應用於免疫細胞異質性研究,並採用大規模細胞數據分析工具One-SENSE來可視化蛋白質轉錄組的數據集。研究發現,靶向轉錄組學方法與蛋白質檢測相結合不需要其他方法那樣高的測序深度,並仍然保持對低豐度轉錄組的高靈敏度。結果顯示,該方法可同時檢測492個免疫相關基因和41個表面蛋白。 為驗證該方法,研究團隊將來自三個健康對照組的27,258個外周血單核細胞分成兩批,一批進行多組學流程分析,另一批進行基於流式細胞的表型分析。
  • 「基因組與轉錄組高通量測序應用最新技術與數據分析」高級實操...
    > 關於舉辦「基因組與轉錄組高通量測序應用最新技術與數據分析由此不斷產生出巨量的分子生物學數據,這些數據有著數量巨大、關係複雜的特點,以至於不利用計算機根本無法實現數據的存儲和分析。隨著生物信息學作為新興學科迅速蓬勃發展,正在改變人們研究生物醫學的傳統方式,高通量測序技術以及數據分析技術已成為探索生物學底層機制和研究人類複雜疾病診斷、治療及預後的重要工具,廣泛應用於生命科學各個領域,是21世紀生命科學與生物技術的重要戰略前沿和主要突破口。
  • 萬字長文 | 單細胞轉錄組分析最佳思路綜述
    本文將詳細介紹單細胞轉錄組數據分析的步驟,包括預處理(質控、歸一化標準化、數據矯正、挑選基因、降維)以及細胞和基因層面的下遊分析。並且作者將整個流程應用在了一個公共數據集作為展示(詳細說明在:https://www.github.com/theislab/single-cell-tutorial),目的是幫助新入坑用戶建立一個知識體系,已入坑用戶更新知識體系。
  • 空間轉錄組測序用於免疫治療研究
    同時,分析當前的免疫治療策略如何改變TME結構和免疫環境也可以幫助指導未來的治療方法。 空間轉錄組檢測技術特點 空間轉錄組檢測技術逐漸受到廣大研究學者的青睞,其不僅可以提供研究對象的轉錄組數據信息,同時還能定位其在組織中的空間位置,這將有助於確定腫瘤異質性的來源,並揭示致病機制、潛在的藥物靶標和新型生物標誌物。