Kneaddata

作者: 可能性之兽 | 来源:发表于2024-03-26 11:29 被阅读0次

Kneaddata是一个用于宏基因组和宏转录组数据的质量控制和去宿主污染的流程工具。它是由哈佛大学的Huttenhower实验室开发的,是bioBakery工具集的一部分。

Kneaddata的主要功能包括:

  1. 质量控制:使用FastQC对原始测序数据进行质量评估,使用Trimmomatic去除低质量reads和adapter序列。

  2. 去除宿主污染:使用Bowtie2将reads比对到指定的宿主基因组(如人类或小鼠),去除能匹配到宿主的reads,保留未匹配到宿主的reads用于后续分析。

  3. 去除污染reads:可选择去除能匹配到污染数据库(如PhiX或UniVec)的reads。

  4. 去除rRNA reads:可选择去除能匹配到rRNA数据库的reads,减少rRNA reads对后续分析的影响。

Kneaddata的典型运行流程如下:

  1. 对原始测序数据进行第一轮质量评估
  2. 使用Trimmomatic去除低质量reads和adapter序列
  3. 去除宿主污染reads
  4. 可选择去除污染reads和rRNA reads
  5. 对过滤后的数据进行第二轮质量评估

Kneaddata的优点在于它集成了多个常用的质控和过滤工具,提供了一个标准化、自动化的流程,方便用户快速完成数据预处理。同时它提供了灵活的参数设置,用户可以根据需要定制不同的过滤条件和参考数据库。

Kneaddata的输出结果包括质控和过滤后的clean reads文件,以及各步骤的处理报告和统计数据,为后续的宏基因组和宏转录组分析提供了高质量的数据。

下载数据库

mkdir -p kneaddata_database
cd -p kneaddata_database/
mkdir human_transcriptome
kneaddata_database --download human_genome bowtie2 ./ 
kneaddata_database --download mouse_C57BL bowtie2 ./
kneaddata_database --download human_transcriptome bowtie2 ./
kneaddata_database --download ribosomal_RNA bowtie2 ./

下载错误

但是有时候会出现这个下载错误,这个时候可以直接对数据进行wget下载然后解压缩

Download URL: http://huttenhower.sph.harvard.edu/kneadData_databases/Homo_sapiens_hg37_and_human_contamination_Bowtie2_v0.1.tar.gz
CRITICAL ERROR: Unable to download and extract from URL: http://huttenhower.sph.harvard.edu/kneadData_databases/Homo_sapiens_hg37_and_human_contamination_Bowtie2_v0.1.tar.gz

def download_tar_and_extract_with_progress_messages(url, filename, folder):
    """
    Download the file at the url
    """
    # check for local file
    local_file = False
    if os.path.isfile(url):
        local_file = True   
 
    if not local_file:
        print("Download URL: " + url) 

    try:
        if not local_file:
            url_handle = urlretrieve(url, filename, reporthook=ReportHook().report)
        else:
            filename = url    
        print("\nExtracting: " + filename)
        tarfile_handle=tarfile.open(filename)
        tarfile_handle.extractall(path=folder)
    except (EnvironmentError, tarfile.ReadError):
        if local_file:
            sys.exit("CRITICAL ERROR: Unable to extract from local file: " + url)
        else:
            sys.exit("CRITICAL ERROR: Unable to download and extract from URL: " + url)

也可以将上面的download_db.py的download_tar_and_extract_with_progress_messages改为下面的函数

import subprocess
def download_tar_and_extract_with_progress_messages(url, filename, folder):
    """
    Download the file at the url using wget command line utility
    """
    # check for local file
    local_file = os.path.isfile(url)
    
    if not local_file:
        print("Download URL: " + url)
        # Construct the wget command with --no-check-certificate option
        command = ['wget', url, '-O', filename, '--no-check-certificate']
        
        try:
            # Run the wget command
            subprocess.check_call(command)
        except subprocess.CalledProcessError as e:
            sys.exit("CRITICAL ERROR: Unable to download from URL: " + url + "\n" + str(e))
    
    # If the file is a local file or download was successful, proceed to extract
    print("\nExtracting: " + filename)
    try:
        with tarfile.open(filename) as tarfile_handle:
            tarfile_handle.extractall(path=folder)
    except tarfile.ReadError as e:
        sys.exit("CRITICAL ERROR: Unable to extract tar file: " + filename + "\n" + str(e))

相关文章

网友评论

    本文标题:Kneaddata

    本文链接:https://www.haomeiwen.com/subject/hfmdtjtx.html