小编Dar*_*en 的帖子

Snakemake:关于如何正确访问配置文件的困惑

这个问题是我之前提出的一个问题,它涉及了解如何使用Snakemake正确访问配置文件。我有一个特定的问题,我需要首先解决,而在理解索引工作原理方面则是一个普遍的问题,其次我要问。

我正在使用snakemake进行运行,并从Alignment / QC到动机分析运行ATAC-seq管道。

答:具体问题

我正在尝试添加一条规则,trim_galore_pe以在对齐之前从我的fastq文件中修剪适配器,并从snakemake引发错误语句,因为生成的输出文件的名称与snakemake期望的名称trim galore不匹配。这是因为我无法解决如何在snakemake文件中正确写入输出文件语句以使名称匹配。

TRIM GALORE包含SRA号生成的名称的示例,例如:

trimmed_fastq_files/SRR2920475_1_val_1.fq.gz

snakemake期望的文件包含示例引用,并且应显示为:

trimmed_fastq_files/Corces2016_4983.7B_Mono_1_val_1.fq.gz

这也会影响规则之后的后续规则trim_galore_pe。我需要找到一种方法来使用配置文件中的信息来生成所需的输出文件。

对于Snakefile中显示的规则之后的所有规则,我需要使用示例名称(即)来命名文件Corces2016_4983.7A_Mono。对于下面的Snakefile中显示的所有FAST_QCMULTIQC规则,在输出文件名结构中具有示例名称也将很有用,它们在当前Snakefile中都已经执行了。

但是,Bowtie2,FASTQC规则的输入以及规则的输入和输出trim_galore_pe需要包含SRA编号。问题始于trim_galore并影响所有下游规则。

尽管我在以前的规则中已经提取了SRA编号,但是当不使用fastq_files配置文件中明确说明的文件夹时,我不确定如何执行此操作。通过引入trim_galore_pe规则,我已将一组新的SRA文件有效地移到了新文件trimmed_fastq_files夹中。如何从包含旧文件夹名称的SRA文件配置文件列表中提取SRA编号,同时引用trimmed_fastq_filesSnakefile中的新文件夹是我问题的症结所在。

我希望这很清楚。

这是我的配置文件:

samples:
    Corces2016_4983.7A_Mono: fastq_files/SRR2920475
    Corces2016_4983.7B_Mono: fastq_files/SRR2920476
cell_types:
    Mono:
    - Corces2016_4983.7A
index: /home/genomes_and_index_files/hg19
Run Code Online (Sandbox Code Playgroud)

这是我的Snakefile:

# read config info into this namespace
configfile: "config.yaml"
print (config['samples'])

rule all:
    input: …
Run Code Online (Sandbox Code Playgroud)

indexing config wildcard curly-braces snakemake

5
推荐指数
1
解决办法
1275
查看次数

Dplyr:仅当行值 > 0 时才使用汇总跨来取列的平均值

我有一个基因表达分数的数据框(细胞x基因)。我还将每个单元格所属的簇存储为一列。

我想计算一组基因(列)的每个簇的平均表达值,但是,我只想在这些计算中包含 > 0 的值。

我对此的尝试如下:

test <- gene_scores_df2 %>% 
  select(all_of(gene_list), Clusters) %>%
  group_by(Clusters) %>%
  summarize(across(c(1:13), ~mean(. > 0)))
Run Code Online (Sandbox Code Playgroud)

这会产生以下小标题:

# A tibble: 16 x 14
   Clusters SLC17A7  GAD1  GAD2 SLC32A1  GLI3   TNC PROX1  SCGN   LHX6 NXPH1 MEIS2 ZFHX3     C3
   <chr>      <dbl> <dbl> <dbl>   <dbl> <dbl> <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl> <dbl>  <dbl>
 1 C1         0.611 0.605 0.817   0.850 0.979 0.590 0.725 0.434 0.275  0.728 0.949 0.886 0.332 
 2 C10        0.484 0.401 0.434   0.401 0.791 0.387 0.431 0.362 0.204 …
Run Code Online (Sandbox Code Playgroud)

r mean dplyr summarize across

3
推荐指数
1
解决办法
684
查看次数

Snakemake:如何有效地使用配置文件

我在Snakemake中使用以下配置文件格式进行一些测序分析实践(我有大量样本,每个样本包含 2 个 fastq 文件:

samples:
Sample1_XY:
    - fastq_files/SRR4356728_1.fastq.gz
    - fastq_files/SRR4356728_2.fastq.gz
Sample2_AB:
    - fastq_files/SRR6257171_1.fastq.gz
    - fastq_files/SRR6257171_2.fastq.gz 
Run Code Online (Sandbox Code Playgroud)

我在管道开始时使用以下规则来运行 fastqc 并对齐 fastqc 文件:

import os
# read config info into this namespace
configfile: "config.yaml"

rule all:
    input:
    expand("FastQC/{sample}_fastqc.zip", sample=config["samples"]),
    expand("bam_files/{sample}.bam", sample=config["samples"]),
    "FastQC/fastq_multiqc.html"

rule fastqc:
    input:
        sample=lambda wildcards: config['samples'][wildcards.sample]
    output:
        # Output needs to end in '_fastqc.html' for multiqc to work
        html="FastQC/{sample}_fastqc.html",
        zip="FastQC/{sample}_fastqc.zip"
    params: ""
        wrapper:
        "0.21.0/bio/fastqc"

rule bowtie2:
    input:
         sample=lambda wildcards: config['samples'][wildcards.sample]
    output:
         "bam_files/{sample}.bam"
    log:
         "logs/bowtie2/{sample}.txt"
    params:
         index=config["index"],  # prefix of …
Run Code Online (Sandbox Code Playgroud)

indexing expand config wildcard snakemake

2
推荐指数
1
解决办法
8356
查看次数

标签 统计

config ×2

indexing ×2

snakemake ×2

wildcard ×2

across ×1

curly-braces ×1

dplyr ×1

expand ×1

mean ×1

r ×1

summarize ×1