单细胞转录组实战01: CellRanger7定量
阅读原文时间:2023年07月09日阅读:1

cd ~/APP
wget -O cellranger-7.1.0.tar.xz "https://cf.10xgenomics.com/releases/cell-exp/cellranger-7.1.0.tar.xz?Expires=1674686023&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9jZi4xMHhnZW5vbWljcy5jb20vcmVsZWFzZXMvY2VsbC1leHAvY2VsbHJhbmdlci03LjEuMC50YXIueHoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE2NzQ2ODYwMjN9fX1dfQ__&Signature=kBEWDvHNogaTb-bmHzd7kHIBIfs8LQmePXusMXNKYpuqbgNHX5Ai0mhB-wv6ig1X5QFZytrl4gYXd8DyNXVo85hRp6Iw9k1UHtuuictpnyNe-5JNocePNKou89k9AOEGoatr6xa9z1VPkOj33FTpG25OpfQowpBrwvNhFF27qoSqw7EcjSWm53zB4QsYqMR~Bi-5MXTEplAxusXnE5A1HtVOo31lsL7cavd88ez9yFcSDIf65~KJR6KqDzqYS3NAcm3MKBWWSeIVAwOWAuHaQONeAew8X4fMb3ql85CpeaCWrQdB-vlUVkQbM0gJY2S7MQ9SJ0B5qUc7qo9UWLXATw__&Key-Pair-Id=APKAI7S6A5RYOXBWRPDA"
tar -xf cellranger-7.1.0.tar.xz
ln -s ~/APP/cellranger-7.1.0/bin/cellranger ~/APP/bin/cellranger
export PATH=$HOME/APP/bin:$PATH

10X提供人和鼠的基因组参考index,其他物种可以是用cellranger自行构建

#>>>down10Xref.sh
# Human reference (GRCh38)  md5sum: dfd654de39bff23917471e7fcc7a00cd
wget https://cf.10xgenomics.com/supp/cell-exp/refdata-gex-GRCh38-2020-A.tar.gz
md5sum refdata-gex-GRCh38-2020-A.tar.gz
# Mouse reference md5sum: 886eeddde8731ffb58552d0bb81f533d
wget https://cf.10xgenomics.com/supp/cell-exp/refdata-gex-mm10-2020-A.tar.gz
md5sum refdata-gex-mm10-2020-A.tar.gz
#<<<down10Xref.sh

nohup sh down10Xref.sh &> down10Xref.sh.log &

https://www.ebi.ac.uk/ena/browser/view/PRJNA510251

mkdir -p ~/Project/LC/data/rawdata
cd ~/Project/LC/data/rawdata
cut -f 11 filereport_read_run_PRJNA510251_tsv.txt | tr ';' '\n' | grep '_[12].fastq.gz' > fq.txt
#>>>downloadFQ.sh
cat fq.txt |while read i
do
ascp -QT -l 300m -P33001 \
-i ~/micromamba/envs/RNA/etc/asperaweb_id_dsa.openssh \
era-fasp@$i \
.
done
#<<<downloadFQ.sh
nohup sh downloadFQ.sh &> downloadFQ.log &
#制作了check.md5文件
cut -f 9 filereport_read_run_PRJNA510251_tsv.txt | sed '1d' | awk -F ';' '{print $(NF-1)"\n"$NF}' > md5.txt
cut -f 7 -d '/' fq.txt | paste md5.txt - > check.md5
rm md5.txt

#检查md5值是否一样,文件是否下载完整
md5sum -c check.md5 &> check.md5.res

10X官网给指出来了文件名规则:

[https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/using/fastq-input]

[https://support.illumina.com/help/BaseSpace_OLH_009008/Content/Source/Informatics/BS/NamingConvention_FASTQ-files-swBS.htm]

[Sample Name]_S1_L00[Lane Number][Read Type]_001.fastq.gz

Where Read Type is one of:

  • I1: Sample index read (optional)
  • I2: Sample index read (optional)
  • R1: Read 1
  • R2: Read 2

用python制作重命名脚本

from collections import Counter
import numpy as np
import pandas as pd

df=pd.read_csv('filereport_read_run_PRJNA510251_tsv.txt',sep='\t')
# Read Type
r=[1,2] * df.shape[0]

# Sample Name
s=np.repeat(df.experiment_alias.values,2)

# Sample Number; Lane Number
s,l = [],[]
for x,y in enumerate(Counter(sn).values()):
    l += list(range(1,int(y/2)+1))
    s += [x+1] * y
l=np.repeat(l,2)

# new file name
new=[f'{a}_S{b}_L00{c}_R{d}_001.fastq.gz' for a,b,c,d in zip(sn,s,l,r)]

# old file name
fq=[]
for i in df.fastq_aspera:
    fq+=i.split(';')
old=[i.split('/')[-1] for i in fq]

#shell script
df2=pd.DataFrame({1:old,2:new})
df2.insert(0,column=0,value='mv')
df2.to_csv('rename.sh',index=False,header=False,sep=' ')

#sh
bash rename.sh

rename.sh前几行

mv SRR8325947_1.fastq.gz GSM3516662_S1_L001_R1_001.fastq.gz
mv SRR8325947_2.fastq.gz GSM3516662_S1_L001_R2_001.fastq.gz
mv SRR8325948_1.fastq.gz GSM3516662_S1_L002_R1_001.fastq.gz
mv SRR8325948_2.fastq.gz GSM3516662_S1_L002_R2_001.fastq.gz
...

因为资源有限,这里只对GSM3516662和GSM3516663两个样本定量。

cd ~/Project/SC10X/rawdata/
mv GSM3516662* fastqs
mv GSM3516663* fastqs
#>>>quantify.sh
fastqs_dir=~/Project/SC10X/rawdata/fastqs
index_dir=~/DataHub/Genomics/10X/refdata-gex-GRCh38-2020-A
output_dir=~/Project/SC10X/quantify
cd ${output_dir}

ls ${fastqs_dir} | cut -d '_' -f 1 | uniq | while read i
do
cellranger count \
    --id $i \
    --transcriptome ${index_dir} \
    --fastqs ${fastqs_dir} \
    --sample $i \
    --localcores 12 \
    --localmem 128
done
#<<<quantify.sh
nohup sh quantify.sh &> quantify.sh.log &

RuntimeError: ~/Project/SC10X/GSM3516662 is not a pipestance directory

  • GSM3516662目录必须是由cellranger创建,也就是说,在运行cellranger之前GSM3516662目录不存在
  • --id 输出文件目录,每个样本一个输出目录
  • --sample是文件重命名哪一步的[Sample Name]

可以参考生信技能树[https://mp.weixin.qq.com/s/VWUmJZnzT7m_7QDjxkbrJw]

需要查看的文件

  • web_summary.html:这个是必须要看的,粗略浏览本次10x样本走cellranger count流程的运行质量
  • filtered_feature_bc_matrix.h5: Python读取表达量矩阵

已经得到表达量矩阵下一步走scanpy分析流程。

Reference

https://mp.weixin.qq.com/s/cu7r7iY2AEKLBdHALzYaCQ

https://mp.weixin.qq.com/s/VWUmJZnzT7m_7QDjxkbrJw

https://mp.weixin.qq.com/s/Fxd9-P79SzvyxwcjUGNL0Q

https://mp.weixin.qq.com/s/6rSMzj8CE-Zw2-EeXyxBYg

https://mp.weixin.qq.com/s/CtQdWfclesbXBVOIPtdzrw

https://blog.csdn.net/herokoking/article/details/103632115

https://www.sci666.com.cn/12239.html

https://zhuanlan.zhihu.com/p/368666622

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章