MAGECK MLE

https://img.shields.io/badge/wrapper_version-v9.15.0-10785b https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/mageck/mle?label=version%20update%20pull%20requests&color=1cb481

Use MAGeCK to call gene essentialities

URL: https://sourceforge.net/p/mageck/wiki/demo/#the-fourth-demo-using-mageck-mle-module

Example

This wrapper can be used in the following way:

rule test_mageck_mle:
    input:
        counts="gene_summary.txt",
        # Optional input files
        design="designmat.txt",
        cnv="cnv_data.txt",
    output:
        mle="test_mageck_mle.genes.tsv",
        mle_log="test_mageck_mle.log",
        sgrna="test_mageck_mle.sgrna.tsv",
    log:
        "test_mageck_mle.log",
    params:
        extra="--cell-line HL60_HAEMATOPOIETIC_AND_LYMPHOID_TISSUE --permutation-round 2",
    wrapper:
        "v9.15.0/bio/mageck/mle"

Note that input, output and log file paths can be chosen freely.

When running with

snakemake --use-conda

the software dependencies will be automatically deployed into an isolated environment before execution.

Notes

If no design table is provided, then at least –day0-label must be given in extra.

Software dependencies

  • mageck=0.5.9.5

  • snakemake-wrapper-utils=0.9.0

Input/Output

Input:

  • count: Path to count table from MAGeCK count

  • design: Optional path to design table

  • cnv: Optional path to CNV table

  • sgrna: Optional path to sgRNA efficiency file

Output:

  • mle: Path to essential genes

  • mle_log: Path to internal logs

  • sgrna: Path to sgrna score ranking

Params

  • extra: Optional parameters besides –count-table, –design-matrix, –output-prefix, –sgrna-efficiency or –cnv-norm.

Authors

  • Thibault Dayris

Code

# coding: utf-8

"""Snakemake wrapper for MaGeCK MLE"""

__author__ = "Thibault Dayris"
__copyright__ = "Copyright 2026, Thibault Dayris"
__email__ = "thibault.dayris@gustaveroussy.fr"
__license__ = "MIT"

from pathlib import Path
from tempfile import TemporaryDirectory
from snakemake.shell import shell
from snakemake_wrapper_utils.snakemake import move_files

extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True, append=True)

cnv = snakemake.input.get("cnv", "")
if cnv:
    extra += f" --cnv-norm {cnv}"

design = snakemake.input.get("design", "")
if design:
    extra += f" --design-matrix {design}"


with TemporaryDirectory() as tempdir:
    temp_prefix = f"{tempdir}/snake_out"
    outfile_mapping = {
        "mle": f"{temp_prefix}.gene_summary.txt",
        "mle_log": f"{temp_prefix}.log",
        "sgrna": f"{temp_prefix}.sgrna_summary.txt",
    }

    shell(
        "mageck mle {extra} --count-table {snakemake.input.counts:q} "
        "--output-prefix {temp_prefix:q} {log} "
    )
    for move_cmd in move_files(snakemake, outfile_mapping, required=False):
        shell("{move_cmd} {log}")