Skip to content

Question: what are the setting optimised for speed rather than memory use? #141

Closed

Description

@vitkl

Hi

I am using the following workflow to read and quantify individual 10x scATAC batches:

def load_atac_tiles(
    sample,
    fragment_file,
    path_to_reference='.../refdata-cellranger-arc-mm10-2020-A-2.0.0/',
    bin_size=500,
):

    chrom_size = {
        str(k): v.values[0]
        for k, v in pd.read_csv(f"{path_to_reference}star/chrNameLength.txt", sep="\t", header=None, index_col=0).T.items()
    }

    data = snap.pp.import_data(
        fragment_file,
        # genome=snap.genome.mm10,
        gff_file=f"{path_to_reference}genes/genes.gtf.gz",
        chrom_size=chrom_size,
        # file="pbmc.h5ad",
        sorted_by_barcode=False,
        chunk_size=100000,
    )
    data.obs['sample'] = sample
    data.obs_names = (
        data.obs['sample']
        + pd.Series("#", index=data.obs_names)
        + data.obs_names
    )

    snap.pl.tsse(data, interactive=False)
    plt.show()

    # quantify ATAC
    snap.pp.add_tile_matrix(
        data, bin_size=bin_size, chunk_size=100000, # exclude_chroms=['chrM', 'chrY', 'M', 'Y'],
    )

    return data

It takes a long time (7 min for 500bp and 45min for 10bp windows => 10s of hours for all samples) - are there any settings that help improve the speed? I can easily get 100-500GB RAM so memory requirements should not be an issue.

Activity

  1. kaizhang commented on Jul 14, 2023

    @kaizhang
    Member

    7 min per sample is actually not bad. There is not much you can do on your side. You may be able to dramatically cut down the running time by running all sample in parallel, e.g., using multiprocessing, if you have a fast file system and a sufficient number of CPU cores.

    Here is an example run time for 92 samples when you process them in parallel on a Linux computer with 8 cores, 64G memory.

    Picture1

  2. kaizhang commented on Jul 14, 2023

    @kaizhang
    Member

    One more thing, setting low_memory=False in import_data may speed up things a little bit in your case.

  3. vitkl commented on Jul 28, 2023

    @vitkl
    Author

    Thanks for explaining and for the suggestions. Speed for 500bp tiles is fine but 10bp is more challenging. I should probably revise how 10bp is computed - rather than tiling everything tile only peaks.

  4. locked and limited conversation to collaborators on Aug 11, 2023
  5. converted this issue into a discussion #146 on Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions