给生物信息学新手的保姆级教程:在Deepin Linux上用Miniconda搞定RNA-seq上游分析

张开发
2026/4/21 8:38:37 15 分钟阅读
给生物信息学新手的保姆级教程:在Deepin Linux上用Miniconda搞定RNA-seq上游分析
生物信息学零基础实战Deepin Linux下RNA-seq分析环境搭建全攻略第一次接触生物信息学分析时面对复杂的命令行操作和五花八门的软件依赖大多数生物学背景的研究者都会感到手足无措。记得我刚开始尝试分析RNA-seq数据时光是软件安装就折腾了整整一周——版本冲突、权限问题、依赖缺失...各种报错让人崩溃。本文将带你避开这些坑在Deepin Linux系统上从零搭建一个稳定可复现的RNA-seq分析环境。Deepin作为一款对新手友好的国产Linux发行版其图形化界面降低了Linux的使用门槛。而Miniconda则是管理生物信息学软件的利器它能解决最让人头疼的软件依赖问题。我们将通过conda虚拟环境隔离不同分析流程再配合国内镜像源加速软件安装最终实现从原始数据到基因表达矩阵的全流程分析。1. 系统准备与Miniconda安装1.1 Deepin系统基础配置Deepin 20.1基于Debian 10默认使用deepin-desktop环境。开始前建议执行系统更新sudo apt update sudo apt upgrade -y安装基础开发工具链sudo apt install -y build-essential git curl wget unzip注意Deepin默认使用sudo无需密码操作时需格外小心。建议通过sudo passwd设置root密码提高安全性。1.2 Miniconda安装与验证Miniconda是Anaconda的精简版只包含conda和Python更适合资源有限的个人电脑。下载最新版Minicondawget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh安装时建议选择no初始化conda避免修改bashrc导致终端启动变慢bash Miniconda3-latest-Linux-x86_64.sh安装完成后手动添加conda到PATHecho export PATH$HOME/miniconda3/bin:$PATH ~/.bashrc source ~/.bashrc验证安装conda --version # 应输出类似conda 23.3.12. 配置高效conda环境2.1 国内镜像源加速默认conda源在国内下载速度极慢替换为清华镜像源conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge conda config --set show_channel_urls yes配置pip镜像源pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple2.2 创建RNA-seq专用环境为避免污染系统环境创建独立conda环境conda create -n rna python3.8 -y conda activate rna关闭自动激活base环境conda config --set auto_activate_base false3. 一站式安装RNA-seq分析工具3.1 核心工具安装在激活的rna环境中安装全套RNA-seq工具conda install -y -c bioconda \ fastqc multiqc \ hisat2 star \ subread samtools \ sra-tools trim-galore常用工具列表工具类别软件名称功能描述质量控制FastQC/MultiQC原始数据质量评估与报告聚合序列比对HISAT2/STAR将reads比对到参考基因组表达量定量featureCounts基于比对结果计算基因表达量数据下载sra-tools从NCBI下载原始测序数据数据预处理trim-galore自动修剪低质量序列和接头3.2 验证关键工具检查主要工具是否安装成功fastqc --version hisat2 --version featureCounts -v若出现命令未找到错误通常是环境未正确激活或PATH设置问题。尝试conda deactivate conda activate rna4. 实战RNA-seq分析流程4.1 数据下载与准备创建项目目录结构mkdir -p rna_seq/{data,scripts,results/{qc,align,counts}} cd rna_seq下载示例数据GSE50177cat EOF SRR_Acc_List.txt SRR957677 SRR957678 SRR957679 SRR957680 EOF prefetch -O data/ $(cat SRR_Acc_List.txt)4.2 质量评估与数据修剪转换SRA为fastq格式parallel -j 2 fastq-dump --split-files --gzip -O data/ data/{} ::: $(cat SRR_Acc_List.txt)运行FastQC质量评估fastqc -o results/qc/ data/*.fastq.gz multiqc results/qc/ -o results/qc/使用trim_galore自动修剪for f in data/*_1.fastq.gz; do trim_galore --paired $f ${f/_1/_2} \ --output_dir results/qc/ \ --cores 2 done4.3 序列比对与表达量计算下载参考基因组以hg38为例wget -P data/ \ ftp://ftp.ensembl.org/pub/current_fasta/homo_sapiens/dna/Homo_sapiens.GRCh38.dna.primary_assembly.fa.gz \ ftp://ftp.ensembl.org/pub/current_gtf/homo_sapiens/Homo_sapiens.GRCh38.107.gtf.gz gunzip data/*.gz建立HISAT2索引hisat2-build data/Homo_sapiens.GRCh38.dna.primary_assembly.fa \ data/hg38_index执行比对for f in results/qc/*_1_val_1.fq.gz; do hisat2 -x data/hg38_index \ -1 $f -2 ${f/_1_val_1/_2_val_2} \ -S results/align/$(basename ${f/_1_val_1.fq.gz/}).sam \ -p 2 --new-summary done使用featureCounts计算表达量featureCounts -T 2 -a data/Homo_sapiens.GRCh38.107.gtf \ -o results/counts/gene_counts.txt \ results/align/*.sam5. 常见问题排查指南5.1 权限问题解决方案Deepin默认用户对系统目录无写权限conda安装时报错时可chown -R $USER:$USER ~/miniconda35.2 软件版本冲突处理遇到依赖冲突时可尝试conda env export environment.yml # 导出当前环境 conda create -n rna_new --file environment.yml # 新建干净环境5.3 低配置电脑优化建议双核处理器建议限制并行线程数-p/--threads参数设为2分批次处理样本增加swap空间避免内存不足sudo fallocate -l 4G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile6. 分析结果解读与下游处理获得gene_counts.txt后可导入R进行差异表达分析。推荐使用DESeq2或edgeR包。在conda环境中安装R环境conda install -y -c conda-forge r-base r-essentials conda install -y -c bioconda bioconductor-deseq2启动R进行后续分析R在R控制台中加载counts数据counts - read.table(results/counts/gene_counts.txt, headerT, row.names1, skip1) colnames(counts) - gsub(results.align.|\\.sam, , colnames(counts)) counts - counts[,6:ncol(counts)] # 提取count列

更多文章