repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
cggh/scikit-allel | allel/io/vcf_read.py | vcf_to_csv | def vcf_to_csv(input, output,
fields=None,
exclude_fields=None,
types=None,
numbers=None,
alt_number=DEFAULT_ALT_NUMBER,
fills=None,
region=None,
tabix='tabix',
transformers=None,
... | python | def vcf_to_csv(input, output,
fields=None,
exclude_fields=None,
types=None,
numbers=None,
alt_number=DEFAULT_ALT_NUMBER,
fills=None,
region=None,
tabix='tabix',
transformers=None,
... | [
"def",
"vcf_to_csv",
"(",
"input",
",",
"output",
",",
"fields",
"=",
"None",
",",
"exclude_fields",
"=",
"None",
",",
"types",
"=",
"None",
",",
"numbers",
"=",
"None",
",",
"alt_number",
"=",
"DEFAULT_ALT_NUMBER",
",",
"fills",
"=",
"None",
",",
"regio... | r"""Read data from a VCF file and write out to a comma-separated values (CSV) file.
Parameters
----------
input : string
{input}
output : string
{output}
fields : list of strings, optional
{fields}
exclude_fields : list of strings, optional
{exclude_fields}
t... | [
"r",
"Read",
"data",
"from",
"a",
"VCF",
"file",
"and",
"write",
"out",
"to",
"a",
"comma",
"-",
"separated",
"values",
"(",
"CSV",
")",
"file",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/io/vcf_read.py#L1902-L1979 |
cggh/scikit-allel | allel/io/vcf_read.py | vcf_to_recarray | def vcf_to_recarray(input,
fields=None,
exclude_fields=None,
types=None,
numbers=None,
alt_number=DEFAULT_ALT_NUMBER,
fills=None,
region=None,
tabix='tabix',
... | python | def vcf_to_recarray(input,
fields=None,
exclude_fields=None,
types=None,
numbers=None,
alt_number=DEFAULT_ALT_NUMBER,
fills=None,
region=None,
tabix='tabix',
... | [
"def",
"vcf_to_recarray",
"(",
"input",
",",
"fields",
"=",
"None",
",",
"exclude_fields",
"=",
"None",
",",
"types",
"=",
"None",
",",
"numbers",
"=",
"None",
",",
"alt_number",
"=",
"DEFAULT_ALT_NUMBER",
",",
"fills",
"=",
"None",
",",
"region",
"=",
"... | Read data from a VCF file into a NumPy recarray.
Parameters
----------
input : string
{input}
fields : list of strings, optional
{fields}
exclude_fields : list of strings, optional
{exclude_fields}
types : dict, optional
{types}
numbers : dict, optional
... | [
"Read",
"data",
"from",
"a",
"VCF",
"file",
"into",
"a",
"NumPy",
"recarray",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/io/vcf_read.py#L2020-L2098 |
cggh/scikit-allel | allel/io/fasta.py | write_fasta | def write_fasta(path, sequences, names, mode='w', width=80):
"""Write nucleotide sequences stored as numpy arrays to a FASTA file.
Parameters
----------
path : string
File path.
sequences : sequence of arrays
One or more ndarrays of dtype 'S1' containing the sequences.
names : ... | python | def write_fasta(path, sequences, names, mode='w', width=80):
"""Write nucleotide sequences stored as numpy arrays to a FASTA file.
Parameters
----------
path : string
File path.
sequences : sequence of arrays
One or more ndarrays of dtype 'S1' containing the sequences.
names : ... | [
"def",
"write_fasta",
"(",
"path",
",",
"sequences",
",",
"names",
",",
"mode",
"=",
"'w'",
",",
"width",
"=",
"80",
")",
":",
"# check inputs",
"if",
"isinstance",
"(",
"sequences",
",",
"np",
".",
"ndarray",
")",
":",
"# single sequence",
"sequences",
... | Write nucleotide sequences stored as numpy arrays to a FASTA file.
Parameters
----------
path : string
File path.
sequences : sequence of arrays
One or more ndarrays of dtype 'S1' containing the sequences.
names : sequence of strings
Names of the sequences.
mode : strin... | [
"Write",
"nucleotide",
"sequences",
"stored",
"as",
"numpy",
"arrays",
"to",
"a",
"FASTA",
"file",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/io/fasta.py#L11-L54 |
cggh/scikit-allel | allel/stats/hw.py | heterozygosity_observed | def heterozygosity_observed(g, fill=np.nan):
"""Calculate the rate of observed heterozygosity for each variant.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, ploidy)
Genotype array.
fill : float, optional
Use this value for variants where all calls are mi... | python | def heterozygosity_observed(g, fill=np.nan):
"""Calculate the rate of observed heterozygosity for each variant.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, ploidy)
Genotype array.
fill : float, optional
Use this value for variants where all calls are mi... | [
"def",
"heterozygosity_observed",
"(",
"g",
",",
"fill",
"=",
"np",
".",
"nan",
")",
":",
"# check inputs",
"if",
"not",
"hasattr",
"(",
"g",
",",
"'count_het'",
")",
"or",
"not",
"hasattr",
"(",
"g",
",",
"'count_called'",
")",
":",
"g",
"=",
"Genotyp... | Calculate the rate of observed heterozygosity for each variant.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, ploidy)
Genotype array.
fill : float, optional
Use this value for variants where all calls are missing.
Returns
-------
ho : ndarray, f... | [
"Calculate",
"the",
"rate",
"of",
"observed",
"heterozygosity",
"for",
"each",
"variant",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/hw.py#L12-L55 |
cggh/scikit-allel | allel/stats/hw.py | heterozygosity_expected | def heterozygosity_expected(af, ploidy, fill=np.nan):
"""Calculate the expected rate of heterozygosity for each variant
under Hardy-Weinberg equilibrium.
Parameters
----------
af : array_like, float, shape (n_variants, n_alleles)
Allele frequencies array.
ploidy : int
Sample pl... | python | def heterozygosity_expected(af, ploidy, fill=np.nan):
"""Calculate the expected rate of heterozygosity for each variant
under Hardy-Weinberg equilibrium.
Parameters
----------
af : array_like, float, shape (n_variants, n_alleles)
Allele frequencies array.
ploidy : int
Sample pl... | [
"def",
"heterozygosity_expected",
"(",
"af",
",",
"ploidy",
",",
"fill",
"=",
"np",
".",
"nan",
")",
":",
"# check inputs",
"af",
"=",
"asarray_ndim",
"(",
"af",
",",
"2",
")",
"# calculate expected heterozygosity",
"out",
"=",
"1",
"-",
"np",
".",
"sum",
... | Calculate the expected rate of heterozygosity for each variant
under Hardy-Weinberg equilibrium.
Parameters
----------
af : array_like, float, shape (n_variants, n_alleles)
Allele frequencies array.
ploidy : int
Sample ploidy.
fill : float, optional
Use this value for v... | [
"Calculate",
"the",
"expected",
"rate",
"of",
"heterozygosity",
"for",
"each",
"variant",
"under",
"Hardy",
"-",
"Weinberg",
"equilibrium",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/hw.py#L58-L103 |
cggh/scikit-allel | allel/stats/hw.py | inbreeding_coefficient | def inbreeding_coefficient(g, fill=np.nan):
"""Calculate the inbreeding coefficient for each variant.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, ploidy)
Genotype array.
fill : float, optional
Use this value for variants where the expected heterozygosit... | python | def inbreeding_coefficient(g, fill=np.nan):
"""Calculate the inbreeding coefficient for each variant.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, ploidy)
Genotype array.
fill : float, optional
Use this value for variants where the expected heterozygosit... | [
"def",
"inbreeding_coefficient",
"(",
"g",
",",
"fill",
"=",
"np",
".",
"nan",
")",
":",
"# check inputs",
"if",
"not",
"hasattr",
"(",
"g",
",",
"'count_het'",
")",
"or",
"not",
"hasattr",
"(",
"g",
",",
"'count_called'",
")",
":",
"g",
"=",
"Genotype... | Calculate the inbreeding coefficient for each variant.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, ploidy)
Genotype array.
fill : float, optional
Use this value for variants where the expected heterozygosity is
zero.
Returns
-------
f ... | [
"Calculate",
"the",
"inbreeding",
"coefficient",
"for",
"each",
"variant",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/hw.py#L106-L157 |
cggh/scikit-allel | allel/stats/mendel.py | mendel_errors | def mendel_errors(parent_genotypes, progeny_genotypes):
"""Locate genotype calls not consistent with Mendelian transmission of
alleles.
Parameters
----------
parent_genotypes : array_like, int, shape (n_variants, 2, 2)
Genotype calls for the two parents.
progeny_genotypes : array_like, ... | python | def mendel_errors(parent_genotypes, progeny_genotypes):
"""Locate genotype calls not consistent with Mendelian transmission of
alleles.
Parameters
----------
parent_genotypes : array_like, int, shape (n_variants, 2, 2)
Genotype calls for the two parents.
progeny_genotypes : array_like, ... | [
"def",
"mendel_errors",
"(",
"parent_genotypes",
",",
"progeny_genotypes",
")",
":",
"# setup",
"parent_genotypes",
"=",
"GenotypeArray",
"(",
"parent_genotypes",
")",
"progeny_genotypes",
"=",
"GenotypeArray",
"(",
"progeny_genotypes",
")",
"check_ploidy",
"(",
"parent... | Locate genotype calls not consistent with Mendelian transmission of
alleles.
Parameters
----------
parent_genotypes : array_like, int, shape (n_variants, 2, 2)
Genotype calls for the two parents.
progeny_genotypes : array_like, int, shape (n_variants, n_progeny, 2)
Genotype calls fo... | [
"Locate",
"genotype",
"calls",
"not",
"consistent",
"with",
"Mendelian",
"transmission",
"of",
"alleles",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/mendel.py#L15-L218 |
cggh/scikit-allel | allel/stats/mendel.py | paint_transmission | def paint_transmission(parent_haplotypes, progeny_haplotypes):
"""Paint haplotypes inherited from a single diploid parent according to
their allelic inheritance.
Parameters
----------
parent_haplotypes : array_like, int, shape (n_variants, 2)
Both haplotypes from a single diploid parent.
... | python | def paint_transmission(parent_haplotypes, progeny_haplotypes):
"""Paint haplotypes inherited from a single diploid parent according to
their allelic inheritance.
Parameters
----------
parent_haplotypes : array_like, int, shape (n_variants, 2)
Both haplotypes from a single diploid parent.
... | [
"def",
"paint_transmission",
"(",
"parent_haplotypes",
",",
"progeny_haplotypes",
")",
":",
"# check inputs",
"parent_haplotypes",
"=",
"HaplotypeArray",
"(",
"parent_haplotypes",
")",
"progeny_haplotypes",
"=",
"HaplotypeArray",
"(",
"progeny_haplotypes",
")",
"if",
"par... | Paint haplotypes inherited from a single diploid parent according to
their allelic inheritance.
Parameters
----------
parent_haplotypes : array_like, int, shape (n_variants, 2)
Both haplotypes from a single diploid parent.
progeny_haplotypes : array_like, int, shape (n_variants, n_progeny)
... | [
"Paint",
"haplotypes",
"inherited",
"from",
"a",
"single",
"diploid",
"parent",
"according",
"to",
"their",
"allelic",
"inheritance",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/mendel.py#L232-L323 |
cggh/scikit-allel | allel/stats/mendel.py | phase_progeny_by_transmission | def phase_progeny_by_transmission(g):
"""Phase progeny genotypes from a trio or cross using Mendelian
transmission.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, 2)
Genotype array, with parents as first two columns and progeny as
remaining columns.
Re... | python | def phase_progeny_by_transmission(g):
"""Phase progeny genotypes from a trio or cross using Mendelian
transmission.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, 2)
Genotype array, with parents as first two columns and progeny as
remaining columns.
Re... | [
"def",
"phase_progeny_by_transmission",
"(",
"g",
")",
":",
"# setup",
"g",
"=",
"GenotypeArray",
"(",
"g",
",",
"dtype",
"=",
"'i1'",
",",
"copy",
"=",
"True",
")",
"check_ploidy",
"(",
"g",
".",
"ploidy",
",",
"2",
")",
"check_min_samples",
"(",
"g",
... | Phase progeny genotypes from a trio or cross using Mendelian
transmission.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, 2)
Genotype array, with parents as first two columns and progeny as
remaining columns.
Returns
-------
g : ndarray, int8, shap... | [
"Phase",
"progeny",
"genotypes",
"from",
"a",
"trio",
"or",
"cross",
"using",
"Mendelian",
"transmission",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/mendel.py#L326-L405 |
cggh/scikit-allel | allel/stats/mendel.py | phase_parents_by_transmission | def phase_parents_by_transmission(g, window_size):
"""Phase parent genotypes from a trio or cross, given progeny genotypes
already phased by Mendelian transmission.
Parameters
----------
g : GenotypeArray
Genotype array, with parents as first two columns and progeny as
remaining col... | python | def phase_parents_by_transmission(g, window_size):
"""Phase parent genotypes from a trio or cross, given progeny genotypes
already phased by Mendelian transmission.
Parameters
----------
g : GenotypeArray
Genotype array, with parents as first two columns and progeny as
remaining col... | [
"def",
"phase_parents_by_transmission",
"(",
"g",
",",
"window_size",
")",
":",
"# setup",
"check_type",
"(",
"g",
",",
"GenotypeArray",
")",
"check_dtype",
"(",
"g",
".",
"values",
",",
"'i1'",
")",
"check_ploidy",
"(",
"g",
".",
"ploidy",
",",
"2",
")",
... | Phase parent genotypes from a trio or cross, given progeny genotypes
already phased by Mendelian transmission.
Parameters
----------
g : GenotypeArray
Genotype array, with parents as first two columns and progeny as
remaining columns, where progeny genotypes are already phased.
wind... | [
"Phase",
"parent",
"genotypes",
"from",
"a",
"trio",
"or",
"cross",
"given",
"progeny",
"genotypes",
"already",
"phased",
"by",
"Mendelian",
"transmission",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/mendel.py#L408-L443 |
cggh/scikit-allel | allel/stats/mendel.py | phase_by_transmission | def phase_by_transmission(g, window_size, copy=True):
"""Phase genotypes in a trio or cross where possible using Mendelian
transmission.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, 2)
Genotype array, with parents as first two columns and progeny as
remai... | python | def phase_by_transmission(g, window_size, copy=True):
"""Phase genotypes in a trio or cross where possible using Mendelian
transmission.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, 2)
Genotype array, with parents as first two columns and progeny as
remai... | [
"def",
"phase_by_transmission",
"(",
"g",
",",
"window_size",
",",
"copy",
"=",
"True",
")",
":",
"# setup",
"g",
"=",
"np",
".",
"asarray",
"(",
"g",
",",
"dtype",
"=",
"'i1'",
")",
"g",
"=",
"GenotypeArray",
"(",
"g",
",",
"copy",
"=",
"copy",
")... | Phase genotypes in a trio or cross where possible using Mendelian
transmission.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, 2)
Genotype array, with parents as first two columns and progeny as
remaining columns.
window_size : int
Number of previou... | [
"Phase",
"genotypes",
"in",
"a",
"trio",
"or",
"cross",
"where",
"possible",
"using",
"Mendelian",
"transmission",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/mendel.py#L446-L485 |
cggh/scikit-allel | allel/chunked/util.py | get_blen_array | def get_blen_array(data, blen=None):
"""Try to guess a reasonable block length to use for block-wise iteration
over `data`."""
if blen is None:
if hasattr(data, 'chunklen'):
# bcolz carray
return data.chunklen
elif hasattr(data, 'chunks') and \
hasa... | python | def get_blen_array(data, blen=None):
"""Try to guess a reasonable block length to use for block-wise iteration
over `data`."""
if blen is None:
if hasattr(data, 'chunklen'):
# bcolz carray
return data.chunklen
elif hasattr(data, 'chunks') and \
hasa... | [
"def",
"get_blen_array",
"(",
"data",
",",
"blen",
"=",
"None",
")",
":",
"if",
"blen",
"is",
"None",
":",
"if",
"hasattr",
"(",
"data",
",",
"'chunklen'",
")",
":",
"# bcolz carray",
"return",
"data",
".",
"chunklen",
"elif",
"hasattr",
"(",
"data",
"... | Try to guess a reasonable block length to use for block-wise iteration
over `data`. | [
"Try",
"to",
"guess",
"a",
"reasonable",
"block",
"length",
"to",
"use",
"for",
"block",
"-",
"wise",
"iteration",
"over",
"data",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/util.py#L96-L120 |
cggh/scikit-allel | allel/chunked/storage_hdf5.py | h5fmem | def h5fmem(**kwargs):
"""Create an in-memory HDF5 file."""
# need a file name even tho nothing is ever written
fn = tempfile.mktemp()
# file creation args
kwargs['mode'] = 'w'
kwargs['driver'] = 'core'
kwargs['backing_store'] = False
# open HDF5 file
h5f = h5py.File(fn, **kwargs)
... | python | def h5fmem(**kwargs):
"""Create an in-memory HDF5 file."""
# need a file name even tho nothing is ever written
fn = tempfile.mktemp()
# file creation args
kwargs['mode'] = 'w'
kwargs['driver'] = 'core'
kwargs['backing_store'] = False
# open HDF5 file
h5f = h5py.File(fn, **kwargs)
... | [
"def",
"h5fmem",
"(",
"*",
"*",
"kwargs",
")",
":",
"# need a file name even tho nothing is ever written",
"fn",
"=",
"tempfile",
".",
"mktemp",
"(",
")",
"# file creation args",
"kwargs",
"[",
"'mode'",
"]",
"=",
"'w'",
"kwargs",
"[",
"'driver'",
"]",
"=",
"'... | Create an in-memory HDF5 file. | [
"Create",
"an",
"in",
"-",
"memory",
"HDF5",
"file",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/storage_hdf5.py#L17-L31 |
cggh/scikit-allel | allel/chunked/storage_hdf5.py | h5ftmp | def h5ftmp(**kwargs):
"""Create an HDF5 file backed by a temporary file."""
# create temporary file name
suffix = kwargs.pop('suffix', '.h5')
prefix = kwargs.pop('prefix', 'scikit_allel_')
tempdir = kwargs.pop('dir', None)
fn = tempfile.mktemp(suffix=suffix, prefix=prefix, dir=tempdir)
atex... | python | def h5ftmp(**kwargs):
"""Create an HDF5 file backed by a temporary file."""
# create temporary file name
suffix = kwargs.pop('suffix', '.h5')
prefix = kwargs.pop('prefix', 'scikit_allel_')
tempdir = kwargs.pop('dir', None)
fn = tempfile.mktemp(suffix=suffix, prefix=prefix, dir=tempdir)
atex... | [
"def",
"h5ftmp",
"(",
"*",
"*",
"kwargs",
")",
":",
"# create temporary file name",
"suffix",
"=",
"kwargs",
".",
"pop",
"(",
"'suffix'",
",",
"'.h5'",
")",
"prefix",
"=",
"kwargs",
".",
"pop",
"(",
"'prefix'",
",",
"'scikit_allel_'",
")",
"tempdir",
"=",
... | Create an HDF5 file backed by a temporary file. | [
"Create",
"an",
"HDF5",
"file",
"backed",
"by",
"a",
"temporary",
"file",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/storage_hdf5.py#L34-L50 |
cggh/scikit-allel | allel/chunked/core.py | store | def store(data, arr, start=0, stop=None, offset=0, blen=None):
"""Copy `data` block-wise into `arr`."""
# setup
blen = _util.get_blen_array(data, blen)
if stop is None:
stop = len(data)
else:
stop = min(stop, len(data))
length = stop - start
if length < 0:
raise Valu... | python | def store(data, arr, start=0, stop=None, offset=0, blen=None):
"""Copy `data` block-wise into `arr`."""
# setup
blen = _util.get_blen_array(data, blen)
if stop is None:
stop = len(data)
else:
stop = min(stop, len(data))
length = stop - start
if length < 0:
raise Valu... | [
"def",
"store",
"(",
"data",
",",
"arr",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"offset",
"=",
"0",
",",
"blen",
"=",
"None",
")",
":",
"# setup",
"blen",
"=",
"_util",
".",
"get_blen_array",
"(",
"data",
",",
"blen",
")",
"if",
... | Copy `data` block-wise into `arr`. | [
"Copy",
"data",
"block",
"-",
"wise",
"into",
"arr",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L16-L34 |
cggh/scikit-allel | allel/chunked/core.py | copy | def copy(data, start=0, stop=None, blen=None, storage=None, create='array',
**kwargs):
"""Copy `data` block-wise into a new array."""
# setup
storage = _util.get_storage(storage)
blen = _util.get_blen_array(data, blen)
if stop is None:
stop = len(data)
else:
stop = min(... | python | def copy(data, start=0, stop=None, blen=None, storage=None, create='array',
**kwargs):
"""Copy `data` block-wise into a new array."""
# setup
storage = _util.get_storage(storage)
blen = _util.get_blen_array(data, blen)
if stop is None:
stop = len(data)
else:
stop = min(... | [
"def",
"copy",
"(",
"data",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"*",
"*",
"kwargs",
")",
":",
"# setup",
"storage",
"=",
"_util",
".",
"get_s... | Copy `data` block-wise into a new array. | [
"Copy",
"data",
"block",
"-",
"wise",
"into",
"a",
"new",
"array",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L37-L62 |
cggh/scikit-allel | allel/chunked/core.py | copy_table | def copy_table(tbl, start=0, stop=None, blen=None, storage=None,
create='table', **kwargs):
"""Copy `tbl` block-wise into a new table."""
# setup
names, columns = _util.check_table_like(tbl)
storage = _util.get_storage(storage)
blen = _util.get_blen_table(tbl, blen)
if stop is No... | python | def copy_table(tbl, start=0, stop=None, blen=None, storage=None,
create='table', **kwargs):
"""Copy `tbl` block-wise into a new table."""
# setup
names, columns = _util.check_table_like(tbl)
storage = _util.get_storage(storage)
blen = _util.get_blen_table(tbl, blen)
if stop is No... | [
"def",
"copy_table",
"(",
"tbl",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'table'",
",",
"*",
"*",
"kwargs",
")",
":",
"# setup",
"names",
",",
"columns",
"=",
"... | Copy `tbl` block-wise into a new table. | [
"Copy",
"tbl",
"block",
"-",
"wise",
"into",
"a",
"new",
"table",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L65-L92 |
cggh/scikit-allel | allel/chunked/core.py | map_blocks | def map_blocks(data, f, blen=None, storage=None, create='array', **kwargs):
"""Apply function `f` block-wise over `data`."""
# setup
storage = _util.get_storage(storage)
if isinstance(data, tuple):
blen = max(_util.get_blen_array(d, blen) for d in data)
else:
blen = _util.get_blen_a... | python | def map_blocks(data, f, blen=None, storage=None, create='array', **kwargs):
"""Apply function `f` block-wise over `data`."""
# setup
storage = _util.get_storage(storage)
if isinstance(data, tuple):
blen = max(_util.get_blen_array(d, blen) for d in data)
else:
blen = _util.get_blen_a... | [
"def",
"map_blocks",
"(",
"data",
",",
"f",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"*",
"*",
"kwargs",
")",
":",
"# setup",
"storage",
"=",
"_util",
".",
"get_storage",
"(",
"storage",
")",
"if",
... | Apply function `f` block-wise over `data`. | [
"Apply",
"function",
"f",
"block",
"-",
"wise",
"over",
"data",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L95-L130 |
cggh/scikit-allel | allel/chunked/core.py | reduce_axis | def reduce_axis(data, reducer, block_reducer, mapper=None, axis=None,
blen=None, storage=None, create='array', **kwargs):
"""Apply an operation to `data` that reduces over one or more axes."""
# setup
storage = _util.get_storage(storage)
blen = _util.get_blen_array(data, blen)
lengt... | python | def reduce_axis(data, reducer, block_reducer, mapper=None, axis=None,
blen=None, storage=None, create='array', **kwargs):
"""Apply an operation to `data` that reduces over one or more axes."""
# setup
storage = _util.get_storage(storage)
blen = _util.get_blen_array(data, blen)
lengt... | [
"def",
"reduce_axis",
"(",
"data",
",",
"reducer",
",",
"block_reducer",
",",
"mapper",
"=",
"None",
",",
"axis",
"=",
"None",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"*",
"*",
"kwargs",
")",
":",
... | Apply an operation to `data` that reduces over one or more axes. | [
"Apply",
"an",
"operation",
"to",
"data",
"that",
"reduces",
"over",
"one",
"or",
"more",
"axes",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L133-L185 |
cggh/scikit-allel | allel/chunked/core.py | amax | def amax(data, axis=None, mapper=None, blen=None, storage=None,
create='array', **kwargs):
"""Compute the maximum value."""
return reduce_axis(data, axis=axis, reducer=np.amax,
block_reducer=np.maximum, mapper=mapper,
blen=blen, storage=storage, create=crea... | python | def amax(data, axis=None, mapper=None, blen=None, storage=None,
create='array', **kwargs):
"""Compute the maximum value."""
return reduce_axis(data, axis=axis, reducer=np.amax,
block_reducer=np.maximum, mapper=mapper,
blen=blen, storage=storage, create=crea... | [
"def",
"amax",
"(",
"data",
",",
"axis",
"=",
"None",
",",
"mapper",
"=",
"None",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"reduce_axis",
"(",
"data",
",",
... | Compute the maximum value. | [
"Compute",
"the",
"maximum",
"value",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L188-L193 |
cggh/scikit-allel | allel/chunked/core.py | amin | def amin(data, axis=None, mapper=None, blen=None, storage=None,
create='array', **kwargs):
"""Compute the minimum value."""
return reduce_axis(data, axis=axis, reducer=np.amin,
block_reducer=np.minimum, mapper=mapper,
blen=blen, storage=storage, create=crea... | python | def amin(data, axis=None, mapper=None, blen=None, storage=None,
create='array', **kwargs):
"""Compute the minimum value."""
return reduce_axis(data, axis=axis, reducer=np.amin,
block_reducer=np.minimum, mapper=mapper,
blen=blen, storage=storage, create=crea... | [
"def",
"amin",
"(",
"data",
",",
"axis",
"=",
"None",
",",
"mapper",
"=",
"None",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"reduce_axis",
"(",
"data",
",",
... | Compute the minimum value. | [
"Compute",
"the",
"minimum",
"value",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L196-L201 |
cggh/scikit-allel | allel/chunked/core.py | asum | def asum(data, axis=None, mapper=None, blen=None, storage=None,
create='array', **kwargs):
"""Compute the sum."""
return reduce_axis(data, axis=axis, reducer=np.sum,
block_reducer=np.add, mapper=mapper,
blen=blen, storage=storage, create=create, **kwargs) | python | def asum(data, axis=None, mapper=None, blen=None, storage=None,
create='array', **kwargs):
"""Compute the sum."""
return reduce_axis(data, axis=axis, reducer=np.sum,
block_reducer=np.add, mapper=mapper,
blen=blen, storage=storage, create=create, **kwargs) | [
"def",
"asum",
"(",
"data",
",",
"axis",
"=",
"None",
",",
"mapper",
"=",
"None",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"reduce_axis",
"(",
"data",
",",
... | Compute the sum. | [
"Compute",
"the",
"sum",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L205-L210 |
cggh/scikit-allel | allel/chunked/core.py | count_nonzero | def count_nonzero(data, mapper=None, blen=None, storage=None,
create='array', **kwargs):
"""Count the number of non-zero elements."""
return reduce_axis(data, reducer=np.count_nonzero,
block_reducer=np.add, mapper=mapper,
blen=blen, storage=storage... | python | def count_nonzero(data, mapper=None, blen=None, storage=None,
create='array', **kwargs):
"""Count the number of non-zero elements."""
return reduce_axis(data, reducer=np.count_nonzero,
block_reducer=np.add, mapper=mapper,
blen=blen, storage=storage... | [
"def",
"count_nonzero",
"(",
"data",
",",
"mapper",
"=",
"None",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"reduce_axis",
"(",
"data",
",",
"reducer",
"=",
"np",... | Count the number of non-zero elements. | [
"Count",
"the",
"number",
"of",
"non",
"-",
"zero",
"elements",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L213-L218 |
cggh/scikit-allel | allel/chunked/core.py | compress | def compress(condition, data, axis=0, out=None, blen=None, storage=None, create='array',
**kwargs):
"""Return selected slices of an array along given axis."""
# setup
if out is not None:
# argument is only there for numpy API compatibility
raise NotImplementedError('out argumen... | python | def compress(condition, data, axis=0, out=None, blen=None, storage=None, create='array',
**kwargs):
"""Return selected slices of an array along given axis."""
# setup
if out is not None:
# argument is only there for numpy API compatibility
raise NotImplementedError('out argumen... | [
"def",
"compress",
"(",
"condition",
",",
"data",
",",
"axis",
"=",
"0",
",",
"out",
"=",
"None",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"*",
"*",
"kwargs",
")",
":",
"# setup",
"if",
"out",
"is... | Return selected slices of an array along given axis. | [
"Return",
"selected",
"slices",
"of",
"an",
"array",
"along",
"given",
"axis",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L221-L270 |
cggh/scikit-allel | allel/chunked/core.py | take | def take(data, indices, axis=0, out=None, mode='raise', blen=None, storage=None,
create='array', **kwargs):
"""Take elements from an array along an axis."""
# setup
if out is not None:
# argument is only there for numpy API compatibility
raise NotImplementedError('out argument is n... | python | def take(data, indices, axis=0, out=None, mode='raise', blen=None, storage=None,
create='array', **kwargs):
"""Take elements from an array along an axis."""
# setup
if out is not None:
# argument is only there for numpy API compatibility
raise NotImplementedError('out argument is n... | [
"def",
"take",
"(",
"data",
",",
"indices",
",",
"axis",
"=",
"0",
",",
"out",
"=",
"None",
",",
"mode",
"=",
"'raise'",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"*",
"*",
"kwargs",
")",
":",
"#... | Take elements from an array along an axis. | [
"Take",
"elements",
"from",
"an",
"array",
"along",
"an",
"axis",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L273-L318 |
cggh/scikit-allel | allel/chunked/core.py | compress_table | def compress_table(condition, tbl, axis=None, out=None, blen=None, storage=None,
create='table', **kwargs):
"""Return selected rows of a table."""
# setup
if axis is not None and axis != 0:
raise NotImplementedError('only axis 0 is supported')
if out is not None:
# ar... | python | def compress_table(condition, tbl, axis=None, out=None, blen=None, storage=None,
create='table', **kwargs):
"""Return selected rows of a table."""
# setup
if axis is not None and axis != 0:
raise NotImplementedError('only axis 0 is supported')
if out is not None:
# ar... | [
"def",
"compress_table",
"(",
"condition",
",",
"tbl",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'table'",
",",
"*",
"*",
"kwargs",
")",
":",
"# setup",
"if",
"axi... | Return selected rows of a table. | [
"Return",
"selected",
"rows",
"of",
"a",
"table",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L321-L352 |
cggh/scikit-allel | allel/chunked/core.py | take_table | def take_table(tbl, indices, axis=None, out=None, mode='raise', blen=None, storage=None,
create='table', **kwargs):
"""Return selected rows of a table."""
# setup
if axis is not None and axis != 0:
raise NotImplementedError('only axis 0 is supported')
if out is not None:
... | python | def take_table(tbl, indices, axis=None, out=None, mode='raise', blen=None, storage=None,
create='table', **kwargs):
"""Return selected rows of a table."""
# setup
if axis is not None and axis != 0:
raise NotImplementedError('only axis 0 is supported')
if out is not None:
... | [
"def",
"take_table",
"(",
"tbl",
",",
"indices",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"mode",
"=",
"'raise'",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'table'",
",",
"*",
"*",
"kwargs",
")",
"... | Return selected rows of a table. | [
"Return",
"selected",
"rows",
"of",
"a",
"table",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L355-L381 |
cggh/scikit-allel | allel/chunked/core.py | subset | def subset(data, sel0=None, sel1=None, blen=None, storage=None, create='array',
**kwargs):
"""Return selected rows and columns of an array."""
# TODO refactor sel0 and sel1 normalization with ndarray.subset
# setup
storage = _util.get_storage(storage)
blen = _util.get_blen_array(data, b... | python | def subset(data, sel0=None, sel1=None, blen=None, storage=None, create='array',
**kwargs):
"""Return selected rows and columns of an array."""
# TODO refactor sel0 and sel1 normalization with ndarray.subset
# setup
storage = _util.get_storage(storage)
blen = _util.get_blen_array(data, b... | [
"def",
"subset",
"(",
"data",
",",
"sel0",
"=",
"None",
",",
"sel1",
"=",
"None",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO refactor sel0 and sel1 normalization with nda... | Return selected rows and columns of an array. | [
"Return",
"selected",
"rows",
"and",
"columns",
"of",
"an",
"array",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L384-L437 |
cggh/scikit-allel | allel/chunked/core.py | concatenate_table | def concatenate_table(tup, blen=None, storage=None, create='table', **kwargs):
"""Stack tables in sequence vertically (row-wise)."""
# setup
storage = _util.get_storage(storage)
if not isinstance(tup, (tuple, list)):
raise ValueError('expected tuple or list, found %r' % tup)
if len(tup) < 2... | python | def concatenate_table(tup, blen=None, storage=None, create='table', **kwargs):
"""Stack tables in sequence vertically (row-wise)."""
# setup
storage = _util.get_storage(storage)
if not isinstance(tup, (tuple, list)):
raise ValueError('expected tuple or list, found %r' % tup)
if len(tup) < 2... | [
"def",
"concatenate_table",
"(",
"tup",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'table'",
",",
"*",
"*",
"kwargs",
")",
":",
"# setup",
"storage",
"=",
"_util",
".",
"get_storage",
"(",
"storage",
")",
"if",
"not",
... | Stack tables in sequence vertically (row-wise). | [
"Stack",
"tables",
"in",
"sequence",
"vertically",
"(",
"row",
"-",
"wise",
")",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L440-L467 |
cggh/scikit-allel | allel/chunked/core.py | concatenate | def concatenate(tup, axis=0, blen=None, storage=None, create='array', **kwargs):
"""Concatenate arrays."""
# setup
storage = _util.get_storage(storage)
if not isinstance(tup, (tuple, list)):
raise ValueError('expected tuple or list, found %r' % tup)
if len(tup) < 2:
raise ValueError... | python | def concatenate(tup, axis=0, blen=None, storage=None, create='array', **kwargs):
"""Concatenate arrays."""
# setup
storage = _util.get_storage(storage)
if not isinstance(tup, (tuple, list)):
raise ValueError('expected tuple or list, found %r' % tup)
if len(tup) < 2:
raise ValueError... | [
"def",
"concatenate",
"(",
"tup",
",",
"axis",
"=",
"0",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"*",
"*",
"kwargs",
")",
":",
"# setup",
"storage",
"=",
"_util",
".",
"get_storage",
"(",
"storage",
... | Concatenate arrays. | [
"Concatenate",
"arrays",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L470-L502 |
cggh/scikit-allel | allel/chunked/core.py | binary_op | def binary_op(data, op, other, blen=None, storage=None, create='array',
**kwargs):
"""Compute a binary operation block-wise over `data`."""
# normalise scalars
if hasattr(other, 'shape') and len(other.shape) == 0:
other = other[()]
if np.isscalar(other):
def f(block):
... | python | def binary_op(data, op, other, blen=None, storage=None, create='array',
**kwargs):
"""Compute a binary operation block-wise over `data`."""
# normalise scalars
if hasattr(other, 'shape') and len(other.shape) == 0:
other = other[()]
if np.isscalar(other):
def f(block):
... | [
"def",
"binary_op",
"(",
"data",
",",
"op",
",",
"other",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"*",
"*",
"kwargs",
")",
":",
"# normalise scalars",
"if",
"hasattr",
"(",
"other",
",",
"'shape'",
"... | Compute a binary operation block-wise over `data`. | [
"Compute",
"a",
"binary",
"operation",
"block",
"-",
"wise",
"over",
"data",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L505-L525 |
cggh/scikit-allel | allel/chunked/core.py | eval_table | def eval_table(tbl, expression, vm='python', blen=None, storage=None,
create='array', vm_kwargs=None, **kwargs):
"""Evaluate `expression` against columns of a table."""
# setup
storage = _util.get_storage(storage)
names, columns = _util.check_table_like(tbl)
length = len(columns[0])
... | python | def eval_table(tbl, expression, vm='python', blen=None, storage=None,
create='array', vm_kwargs=None, **kwargs):
"""Evaluate `expression` against columns of a table."""
# setup
storage = _util.get_storage(storage)
names, columns = _util.check_table_like(tbl)
length = len(columns[0])
... | [
"def",
"eval_table",
"(",
"tbl",
",",
"expression",
",",
"vm",
"=",
"'python'",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"vm_kwargs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# setup",
"storag... | Evaluate `expression` against columns of a table. | [
"Evaluate",
"expression",
"against",
"columns",
"of",
"a",
"table",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L545-L586 |
cggh/scikit-allel | allel/model/util.py | create_allele_mapping | def create_allele_mapping(ref, alt, alleles, dtype='i1'):
"""Create an array mapping variant alleles into a different allele index
system.
Parameters
----------
ref : array_like, S1, shape (n_variants,)
Reference alleles.
alt : array_like, S1, shape (n_variants, n_alt_alleles)
A... | python | def create_allele_mapping(ref, alt, alleles, dtype='i1'):
"""Create an array mapping variant alleles into a different allele index
system.
Parameters
----------
ref : array_like, S1, shape (n_variants,)
Reference alleles.
alt : array_like, S1, shape (n_variants, n_alt_alleles)
A... | [
"def",
"create_allele_mapping",
"(",
"ref",
",",
"alt",
",",
"alleles",
",",
"dtype",
"=",
"'i1'",
")",
":",
"ref",
"=",
"asarray_ndim",
"(",
"ref",
",",
"1",
")",
"alt",
"=",
"asarray_ndim",
"(",
"alt",
",",
"1",
",",
"2",
")",
"alleles",
"=",
"as... | Create an array mapping variant alleles into a different allele index
system.
Parameters
----------
ref : array_like, S1, shape (n_variants,)
Reference alleles.
alt : array_like, S1, shape (n_variants, n_alt_alleles)
Alternate alleles.
alleles : array_like, S1, shape (n_variants... | [
"Create",
"an",
"array",
"mapping",
"variant",
"alleles",
"into",
"a",
"different",
"allele",
"index",
"system",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/util.py#L17-L98 |
cggh/scikit-allel | allel/model/util.py | locate_fixed_differences | def locate_fixed_differences(ac1, ac2):
"""Locate variants with no shared alleles between two populations.
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population.
ac2 : array_like, int, shape (n_variants, n_alleles)
A... | python | def locate_fixed_differences(ac1, ac2):
"""Locate variants with no shared alleles between two populations.
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population.
ac2 : array_like, int, shape (n_variants, n_alleles)
A... | [
"def",
"locate_fixed_differences",
"(",
"ac1",
",",
"ac2",
")",
":",
"# check inputs",
"ac1",
"=",
"asarray_ndim",
"(",
"ac1",
",",
"2",
")",
"ac2",
"=",
"asarray_ndim",
"(",
"ac2",
",",
"2",
")",
"check_dim0_aligned",
"(",
"ac1",
",",
"ac2",
")",
"ac1",... | Locate variants with no shared alleles between two populations.
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population.
ac2 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the second population.
... | [
"Locate",
"variants",
"with",
"no",
"shared",
"alleles",
"between",
"two",
"populations",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/util.py#L101-L157 |
cggh/scikit-allel | allel/model/util.py | locate_private_alleles | def locate_private_alleles(*acs):
"""Locate alleles that are found only in a single population.
Parameters
----------
*acs : array_like, int, shape (n_variants, n_alleles)
Allele counts arrays from each population.
Returns
-------
loc : ndarray, bool, shape (n_variants, n_alleles)
... | python | def locate_private_alleles(*acs):
"""Locate alleles that are found only in a single population.
Parameters
----------
*acs : array_like, int, shape (n_variants, n_alleles)
Allele counts arrays from each population.
Returns
-------
loc : ndarray, bool, shape (n_variants, n_alleles)
... | [
"def",
"locate_private_alleles",
"(",
"*",
"acs",
")",
":",
"# check inputs",
"acs",
"=",
"[",
"asarray_ndim",
"(",
"ac",
",",
"2",
")",
"for",
"ac",
"in",
"acs",
"]",
"check_dim0_aligned",
"(",
"*",
"acs",
")",
"acs",
"=",
"ensure_dim1_aligned",
"(",
"*... | Locate alleles that are found only in a single population.
Parameters
----------
*acs : array_like, int, shape (n_variants, n_alleles)
Allele counts arrays from each population.
Returns
-------
loc : ndarray, bool, shape (n_variants, n_alleles)
Boolean array where elements are ... | [
"Locate",
"alleles",
"that",
"are",
"found",
"only",
"in",
"a",
"single",
"population",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/util.py#L160-L213 |
cggh/scikit-allel | allel/stats/fst.py | weir_cockerham_fst | def weir_cockerham_fst(g, subpops, max_allele=None, blen=None):
"""Compute the variance components from the analyses of variance of
allele frequencies according to Weir and Cockerham (1984).
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, ploidy)
Genotype array.
... | python | def weir_cockerham_fst(g, subpops, max_allele=None, blen=None):
"""Compute the variance components from the analyses of variance of
allele frequencies according to Weir and Cockerham (1984).
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, ploidy)
Genotype array.
... | [
"def",
"weir_cockerham_fst",
"(",
"g",
",",
"subpops",
",",
"max_allele",
"=",
"None",
",",
"blen",
"=",
"None",
")",
":",
"# check inputs",
"if",
"not",
"hasattr",
"(",
"g",
",",
"'shape'",
")",
"or",
"not",
"hasattr",
"(",
"g",
",",
"'ndim'",
")",
... | Compute the variance components from the analyses of variance of
allele frequencies according to Weir and Cockerham (1984).
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, ploidy)
Genotype array.
subpops : sequence of sequences of ints
Sample indices for eac... | [
"Compute",
"the",
"variance",
"components",
"from",
"the",
"analyses",
"of",
"variance",
"of",
"allele",
"frequencies",
"according",
"to",
"Weir",
"and",
"Cockerham",
"(",
"1984",
")",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/fst.py#L25-L135 |
cggh/scikit-allel | allel/stats/fst.py | hudson_fst | def hudson_fst(ac1, ac2, fill=np.nan):
"""Calculate the numerator and denominator for Fst estimation using the
method of Hudson (1992) elaborated by Bhatia et al. (2013).
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population... | python | def hudson_fst(ac1, ac2, fill=np.nan):
"""Calculate the numerator and denominator for Fst estimation using the
method of Hudson (1992) elaborated by Bhatia et al. (2013).
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population... | [
"def",
"hudson_fst",
"(",
"ac1",
",",
"ac2",
",",
"fill",
"=",
"np",
".",
"nan",
")",
":",
"# flake8: noqa",
"# check inputs",
"ac1",
"=",
"asarray_ndim",
"(",
"ac1",
",",
"2",
")",
"ac2",
"=",
"asarray_ndim",
"(",
"ac2",
",",
"2",
")",
"check_dim0_ali... | Calculate the numerator and denominator for Fst estimation using the
method of Hudson (1992) elaborated by Bhatia et al. (2013).
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population.
ac2 : array_like, int, shape (n_variants... | [
"Calculate",
"the",
"numerator",
"and",
"denominator",
"for",
"Fst",
"estimation",
"using",
"the",
"method",
"of",
"Hudson",
"(",
"1992",
")",
"elaborated",
"by",
"Bhatia",
"et",
"al",
".",
"(",
"2013",
")",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/fst.py#L250-L327 |
cggh/scikit-allel | allel/stats/fst.py | patterson_fst | def patterson_fst(aca, acb):
"""Estimator of differentiation between populations A and B based on the
F2 parameter.
Parameters
----------
aca : array_like, int, shape (n_variants, 2)
Allele counts for population A.
acb : array_like, int, shape (n_variants, 2)
Allele counts for p... | python | def patterson_fst(aca, acb):
"""Estimator of differentiation between populations A and B based on the
F2 parameter.
Parameters
----------
aca : array_like, int, shape (n_variants, 2)
Allele counts for population A.
acb : array_like, int, shape (n_variants, 2)
Allele counts for p... | [
"def",
"patterson_fst",
"(",
"aca",
",",
"acb",
")",
":",
"from",
"allel",
".",
"stats",
".",
"admixture",
"import",
"patterson_f2",
",",
"h_hat",
"num",
"=",
"patterson_f2",
"(",
"aca",
",",
"acb",
")",
"den",
"=",
"num",
"+",
"h_hat",
"(",
"aca",
"... | Estimator of differentiation between populations A and B based on the
F2 parameter.
Parameters
----------
aca : array_like, int, shape (n_variants, 2)
Allele counts for population A.
acb : array_like, int, shape (n_variants, 2)
Allele counts for population B.
Returns
------... | [
"Estimator",
"of",
"differentiation",
"between",
"populations",
"A",
"and",
"B",
"based",
"on",
"the",
"F2",
"parameter",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/fst.py#L330-L360 |
cggh/scikit-allel | allel/stats/fst.py | windowed_weir_cockerham_fst | def windowed_weir_cockerham_fst(pos, g, subpops, size=None, start=None,
stop=None, step=None, windows=None,
fill=np.nan, max_allele=None):
"""Estimate average Fst in windows over a single chromosome/contig,
following the method of Weir and Cockerha... | python | def windowed_weir_cockerham_fst(pos, g, subpops, size=None, start=None,
stop=None, step=None, windows=None,
fill=np.nan, max_allele=None):
"""Estimate average Fst in windows over a single chromosome/contig,
following the method of Weir and Cockerha... | [
"def",
"windowed_weir_cockerham_fst",
"(",
"pos",
",",
"g",
",",
"subpops",
",",
"size",
"=",
"None",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"None",
",",
"windows",
"=",
"None",
",",
"fill",
"=",
"np",
".",
"nan",
",... | Estimate average Fst in windows over a single chromosome/contig,
following the method of Weir and Cockerham (1984).
Parameters
----------
pos : array_like, int, shape (n_items,)
Variant positions, using 1-based coordinates, in ascending order.
g : array_like, int, shape (n_variants, n_sampl... | [
"Estimate",
"average",
"Fst",
"in",
"windows",
"over",
"a",
"single",
"chromosome",
"/",
"contig",
"following",
"the",
"method",
"of",
"Weir",
"and",
"Cockerham",
"(",
"1984",
")",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/fst.py#L363-L421 |
cggh/scikit-allel | allel/stats/fst.py | windowed_hudson_fst | def windowed_hudson_fst(pos, ac1, ac2, size=None, start=None, stop=None,
step=None, windows=None, fill=np.nan):
"""Estimate average Fst in windows over a single chromosome/contig,
following the method of Hudson (1992) elaborated by Bhatia et al. (2013).
Parameters
----------
... | python | def windowed_hudson_fst(pos, ac1, ac2, size=None, start=None, stop=None,
step=None, windows=None, fill=np.nan):
"""Estimate average Fst in windows over a single chromosome/contig,
following the method of Hudson (1992) elaborated by Bhatia et al. (2013).
Parameters
----------
... | [
"def",
"windowed_hudson_fst",
"(",
"pos",
",",
"ac1",
",",
"ac2",
",",
"size",
"=",
"None",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"None",
",",
"windows",
"=",
"None",
",",
"fill",
"=",
"np",
".",
"nan",
")",
":",
... | Estimate average Fst in windows over a single chromosome/contig,
following the method of Hudson (1992) elaborated by Bhatia et al. (2013).
Parameters
----------
pos : array_like, int, shape (n_items,)
Variant positions, using 1-based coordinates, in ascending order.
ac1 : array_like, int, s... | [
"Estimate",
"average",
"Fst",
"in",
"windows",
"over",
"a",
"single",
"chromosome",
"/",
"contig",
"following",
"the",
"method",
"of",
"Hudson",
"(",
"1992",
")",
"elaborated",
"by",
"Bhatia",
"et",
"al",
".",
"(",
"2013",
")",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/fst.py#L424-L479 |
cggh/scikit-allel | allel/stats/fst.py | moving_weir_cockerham_fst | def moving_weir_cockerham_fst(g, subpops, size, start=0, stop=None, step=None,
max_allele=None):
"""Estimate average Fst in moving windows over a single chromosome/contig,
following the method of Weir and Cockerham (1984).
Parameters
----------
g : array_like, int, sha... | python | def moving_weir_cockerham_fst(g, subpops, size, start=0, stop=None, step=None,
max_allele=None):
"""Estimate average Fst in moving windows over a single chromosome/contig,
following the method of Weir and Cockerham (1984).
Parameters
----------
g : array_like, int, sha... | [
"def",
"moving_weir_cockerham_fst",
"(",
"g",
",",
"subpops",
",",
"size",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"None",
",",
"max_allele",
"=",
"None",
")",
":",
"# calculate per-variant values",
"a",
",",
"b",
",",
"c",
... | Estimate average Fst in moving windows over a single chromosome/contig,
following the method of Weir and Cockerham (1984).
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, ploidy)
Genotype array.
subpops : sequence of sequences of ints
Sample indices for each... | [
"Estimate",
"average",
"Fst",
"in",
"moving",
"windows",
"over",
"a",
"single",
"chromosome",
"/",
"contig",
"following",
"the",
"method",
"of",
"Weir",
"and",
"Cockerham",
"(",
"1984",
")",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/fst.py#L540-L582 |
cggh/scikit-allel | allel/stats/fst.py | moving_hudson_fst | def moving_hudson_fst(ac1, ac2, size, start=0, stop=None, step=None):
"""Estimate average Fst in moving windows over a single chromosome/contig,
following the method of Hudson (1992) elaborated by Bhatia et al. (2013).
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
... | python | def moving_hudson_fst(ac1, ac2, size, start=0, stop=None, step=None):
"""Estimate average Fst in moving windows over a single chromosome/contig,
following the method of Hudson (1992) elaborated by Bhatia et al. (2013).
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
... | [
"def",
"moving_hudson_fst",
"(",
"ac1",
",",
"ac2",
",",
"size",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"None",
")",
":",
"# calculate per-variant values",
"num",
",",
"den",
"=",
"hudson_fst",
"(",
"ac1",
",",
"ac2",
",",
... | Estimate average Fst in moving windows over a single chromosome/contig,
following the method of Hudson (1992) elaborated by Bhatia et al. (2013).
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population.
ac2 : array_like, int, ... | [
"Estimate",
"average",
"Fst",
"in",
"moving",
"windows",
"over",
"a",
"single",
"chromosome",
"/",
"contig",
"following",
"the",
"method",
"of",
"Hudson",
"(",
"1992",
")",
"elaborated",
"by",
"Bhatia",
"et",
"al",
".",
"(",
"2013",
")",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/fst.py#L585-L624 |
cggh/scikit-allel | allel/stats/fst.py | moving_patterson_fst | def moving_patterson_fst(ac1, ac2, size, start=0, stop=None, step=None):
"""Estimate average Fst in moving windows over a single chromosome/contig,
following the method of Patterson (2012).
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from t... | python | def moving_patterson_fst(ac1, ac2, size, start=0, stop=None, step=None):
"""Estimate average Fst in moving windows over a single chromosome/contig,
following the method of Patterson (2012).
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from t... | [
"def",
"moving_patterson_fst",
"(",
"ac1",
",",
"ac2",
",",
"size",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"None",
")",
":",
"# calculate per-variant values",
"num",
",",
"den",
"=",
"patterson_fst",
"(",
"ac1",
",",
"ac2",
... | Estimate average Fst in moving windows over a single chromosome/contig,
following the method of Patterson (2012).
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population.
ac2 : array_like, int, shape (n_variants, n_alleles)
... | [
"Estimate",
"average",
"Fst",
"in",
"moving",
"windows",
"over",
"a",
"single",
"chromosome",
"/",
"contig",
"following",
"the",
"method",
"of",
"Patterson",
"(",
"2012",
")",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/fst.py#L627-L666 |
cggh/scikit-allel | allel/stats/fst.py | average_weir_cockerham_fst | def average_weir_cockerham_fst(g, subpops, blen, max_allele=None):
"""Estimate average Fst and standard error using the block-jackknife.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, ploidy)
Genotype array.
subpops : sequence of sequences of ints
Sample in... | python | def average_weir_cockerham_fst(g, subpops, blen, max_allele=None):
"""Estimate average Fst and standard error using the block-jackknife.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, ploidy)
Genotype array.
subpops : sequence of sequences of ints
Sample in... | [
"def",
"average_weir_cockerham_fst",
"(",
"g",
",",
"subpops",
",",
"blen",
",",
"max_allele",
"=",
"None",
")",
":",
"# calculate per-variant values",
"a",
",",
"b",
",",
"c",
"=",
"weir_cockerham_fst",
"(",
"g",
",",
"subpops",
",",
"max_allele",
"=",
"max... | Estimate average Fst and standard error using the block-jackknife.
Parameters
----------
g : array_like, int, shape (n_variants, n_samples, ploidy)
Genotype array.
subpops : sequence of sequences of ints
Sample indices for each subpopulation.
blen : int
Block size (number of... | [
"Estimate",
"average",
"Fst",
"and",
"standard",
"error",
"using",
"the",
"block",
"-",
"jackknife",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/fst.py#L669-L716 |
cggh/scikit-allel | allel/stats/fst.py | average_hudson_fst | def average_hudson_fst(ac1, ac2, blen):
"""Estimate average Fst between two populations and standard error using
the block-jackknife.
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population.
ac2 : array_like, int, shape (n... | python | def average_hudson_fst(ac1, ac2, blen):
"""Estimate average Fst between two populations and standard error using
the block-jackknife.
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population.
ac2 : array_like, int, shape (n... | [
"def",
"average_hudson_fst",
"(",
"ac1",
",",
"ac2",
",",
"blen",
")",
":",
"# calculate per-variant values",
"num",
",",
"den",
"=",
"hudson_fst",
"(",
"ac1",
",",
"ac2",
",",
"fill",
"=",
"np",
".",
"nan",
")",
"# calculate overall estimate",
"fst",
"=",
... | Estimate average Fst between two populations and standard error using
the block-jackknife.
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population.
ac2 : array_like, int, shape (n_variants, n_alleles)
Allele counts arr... | [
"Estimate",
"average",
"Fst",
"between",
"two",
"populations",
"and",
"standard",
"error",
"using",
"the",
"block",
"-",
"jackknife",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/fst.py#L719-L762 |
cggh/scikit-allel | allel/stats/fst.py | average_patterson_fst | def average_patterson_fst(ac1, ac2, blen):
"""Estimate average Fst between two populations and standard error using
the block-jackknife.
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population.
ac2 : array_like, int, shape... | python | def average_patterson_fst(ac1, ac2, blen):
"""Estimate average Fst between two populations and standard error using
the block-jackknife.
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population.
ac2 : array_like, int, shape... | [
"def",
"average_patterson_fst",
"(",
"ac1",
",",
"ac2",
",",
"blen",
")",
":",
"# calculate per-variant values",
"num",
",",
"den",
"=",
"patterson_fst",
"(",
"ac1",
",",
"ac2",
")",
"# calculate overall estimate",
"fst",
"=",
"np",
".",
"nansum",
"(",
"num",
... | Estimate average Fst between two populations and standard error using
the block-jackknife.
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array from the first population.
ac2 : array_like, int, shape (n_variants, n_alleles)
Allele counts arr... | [
"Estimate",
"average",
"Fst",
"between",
"two",
"populations",
"and",
"standard",
"error",
"using",
"the",
"block",
"-",
"jackknife",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/fst.py#L765-L808 |
cggh/scikit-allel | allel/stats/ld.py | rogers_huff_r | def rogers_huff_r(gn):
"""Estimate the linkage disequilibrium parameter *r* for each pair of
variants using the method of Rogers and Huff (2008).
Parameters
----------
gn : array_like, int8, shape (n_variants, n_samples)
Diploid genotypes at biallelic variants, coded as the number of
... | python | def rogers_huff_r(gn):
"""Estimate the linkage disequilibrium parameter *r* for each pair of
variants using the method of Rogers and Huff (2008).
Parameters
----------
gn : array_like, int8, shape (n_variants, n_samples)
Diploid genotypes at biallelic variants, coded as the number of
... | [
"def",
"rogers_huff_r",
"(",
"gn",
")",
":",
"# check inputs",
"gn",
"=",
"asarray_ndim",
"(",
"gn",
",",
"2",
",",
"dtype",
"=",
"'i1'",
")",
"gn",
"=",
"memoryview_safe",
"(",
"gn",
")",
"# compute correlation coefficients",
"r",
"=",
"gn_pairwise_corrcoef_i... | Estimate the linkage disequilibrium parameter *r* for each pair of
variants using the method of Rogers and Huff (2008).
Parameters
----------
gn : array_like, int8, shape (n_variants, n_samples)
Diploid genotypes at biallelic variants, coded as the number of
alternate alleles per call (... | [
"Estimate",
"the",
"linkage",
"disequilibrium",
"parameter",
"*",
"r",
"*",
"for",
"each",
"pair",
"of",
"variants",
"using",
"the",
"method",
"of",
"Rogers",
"and",
"Huff",
"(",
"2008",
")",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/ld.py#L16-L72 |
cggh/scikit-allel | allel/stats/ld.py | rogers_huff_r_between | def rogers_huff_r_between(gna, gnb):
"""Estimate the linkage disequilibrium parameter *r* for each pair of
variants between the two input arrays, using the method of Rogers and
Huff (2008).
Parameters
----------
gna, gnb : array_like, int8, shape (n_variants, n_samples)
Diploid genotype... | python | def rogers_huff_r_between(gna, gnb):
"""Estimate the linkage disequilibrium parameter *r* for each pair of
variants between the two input arrays, using the method of Rogers and
Huff (2008).
Parameters
----------
gna, gnb : array_like, int8, shape (n_variants, n_samples)
Diploid genotype... | [
"def",
"rogers_huff_r_between",
"(",
"gna",
",",
"gnb",
")",
":",
"# check inputs",
"gna",
"=",
"asarray_ndim",
"(",
"gna",
",",
"2",
",",
"dtype",
"=",
"'i1'",
")",
"gnb",
"=",
"asarray_ndim",
"(",
"gnb",
",",
"2",
",",
"dtype",
"=",
"'i1'",
")",
"g... | Estimate the linkage disequilibrium parameter *r* for each pair of
variants between the two input arrays, using the method of Rogers and
Huff (2008).
Parameters
----------
gna, gnb : array_like, int8, shape (n_variants, n_samples)
Diploid genotypes at biallelic variants, coded as the number... | [
"Estimate",
"the",
"linkage",
"disequilibrium",
"parameter",
"*",
"r",
"*",
"for",
"each",
"pair",
"of",
"variants",
"between",
"the",
"two",
"input",
"arrays",
"using",
"the",
"method",
"of",
"Rogers",
"and",
"Huff",
"(",
"2008",
")",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/ld.py#L75-L106 |
cggh/scikit-allel | allel/stats/ld.py | locate_unlinked | def locate_unlinked(gn, size=100, step=20, threshold=.1, blen=None):
"""Locate variants in approximate linkage equilibrium, where r**2 is
below the given `threshold`.
Parameters
----------
gn : array_like, int8, shape (n_variants, n_samples)
Diploid genotypes at biallelic variants, coded as... | python | def locate_unlinked(gn, size=100, step=20, threshold=.1, blen=None):
"""Locate variants in approximate linkage equilibrium, where r**2 is
below the given `threshold`.
Parameters
----------
gn : array_like, int8, shape (n_variants, n_samples)
Diploid genotypes at biallelic variants, coded as... | [
"def",
"locate_unlinked",
"(",
"gn",
",",
"size",
"=",
"100",
",",
"step",
"=",
"20",
",",
"threshold",
"=",
".1",
",",
"blen",
"=",
"None",
")",
":",
"# check inputs",
"if",
"not",
"hasattr",
"(",
"gn",
",",
"'shape'",
")",
"or",
"not",
"hasattr",
... | Locate variants in approximate linkage equilibrium, where r**2 is
below the given `threshold`.
Parameters
----------
gn : array_like, int8, shape (n_variants, n_samples)
Diploid genotypes at biallelic variants, coded as the number of
alternate alleles per call (i.e., 0 = hom ref, 1 = he... | [
"Locate",
"variants",
"in",
"approximate",
"linkage",
"equilibrium",
"where",
"r",
"**",
"2",
"is",
"below",
"the",
"given",
"threshold",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/ld.py#L109-L161 |
cggh/scikit-allel | allel/stats/ld.py | windowed_r_squared | def windowed_r_squared(pos, gn, size=None, start=None, stop=None, step=None,
windows=None, fill=np.nan, percentile=50):
"""Summarise linkage disequilibrium in windows over a single
chromosome/contig.
Parameters
----------
pos : array_like, int, shape (n_items,)
The it... | python | def windowed_r_squared(pos, gn, size=None, start=None, stop=None, step=None,
windows=None, fill=np.nan, percentile=50):
"""Summarise linkage disequilibrium in windows over a single
chromosome/contig.
Parameters
----------
pos : array_like, int, shape (n_items,)
The it... | [
"def",
"windowed_r_squared",
"(",
"pos",
",",
"gn",
",",
"size",
"=",
"None",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"None",
",",
"windows",
"=",
"None",
",",
"fill",
"=",
"np",
".",
"nan",
",",
"percentile",
"=",
... | Summarise linkage disequilibrium in windows over a single
chromosome/contig.
Parameters
----------
pos : array_like, int, shape (n_items,)
The item positions in ascending order, using 1-based coordinates..
gn : array_like, int8, shape (n_variants, n_samples)
Diploid genotypes at bia... | [
"Summarise",
"linkage",
"disequilibrium",
"in",
"windows",
"over",
"a",
"single",
"chromosome",
"/",
"contig",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/ld.py#L164-L230 |
cggh/scikit-allel | allel/stats/ld.py | plot_pairwise_ld | def plot_pairwise_ld(m, colorbar=True, ax=None, imshow_kwargs=None):
"""Plot a matrix of genotype linkage disequilibrium values between
all pairs of variants.
Parameters
----------
m : array_like
Array of linkage disequilibrium values in condensed form.
colorbar : bool, optional
... | python | def plot_pairwise_ld(m, colorbar=True, ax=None, imshow_kwargs=None):
"""Plot a matrix of genotype linkage disequilibrium values between
all pairs of variants.
Parameters
----------
m : array_like
Array of linkage disequilibrium values in condensed form.
colorbar : bool, optional
... | [
"def",
"plot_pairwise_ld",
"(",
"m",
",",
"colorbar",
"=",
"True",
",",
"ax",
"=",
"None",
",",
"imshow_kwargs",
"=",
"None",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"# check inputs",
"m_square",
"=",
"ensure_square",
"(",
"m",
")",
... | Plot a matrix of genotype linkage disequilibrium values between
all pairs of variants.
Parameters
----------
m : array_like
Array of linkage disequilibrium values in condensed form.
colorbar : bool, optional
If True, add a colorbar to the current figure.
ax : axes, optional
... | [
"Plot",
"a",
"matrix",
"of",
"genotype",
"linkage",
"disequilibrium",
"values",
"between",
"all",
"pairs",
"of",
"variants",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/ld.py#L233-L292 |
cggh/scikit-allel | allel/io/util.py | array_to_hdf5 | def array_to_hdf5(a, parent, name, **kwargs):
"""Write a Numpy array to an HDF5 dataset.
Parameters
----------
a : ndarray
Data to write.
parent : string or h5py group
Parent HDF5 file or group. If a string, will be treated as HDF5 file
name.
name : string
Name o... | python | def array_to_hdf5(a, parent, name, **kwargs):
"""Write a Numpy array to an HDF5 dataset.
Parameters
----------
a : ndarray
Data to write.
parent : string or h5py group
Parent HDF5 file or group. If a string, will be treated as HDF5 file
name.
name : string
Name o... | [
"def",
"array_to_hdf5",
"(",
"a",
",",
"parent",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"h5py",
"h5f",
"=",
"None",
"if",
"isinstance",
"(",
"parent",
",",
"str",
")",
":",
"h5f",
"=",
"h5py",
".",
"File",
"(",
"parent",
",",
"... | Write a Numpy array to an HDF5 dataset.
Parameters
----------
a : ndarray
Data to write.
parent : string or h5py group
Parent HDF5 file or group. If a string, will be treated as HDF5 file
name.
name : string
Name or path of dataset to write data into.
kwargs : ke... | [
"Write",
"a",
"Numpy",
"array",
"to",
"an",
"HDF5",
"dataset",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/io/util.py#L11-L51 |
cggh/scikit-allel | allel/io/util.py | recarray_from_hdf5_group | def recarray_from_hdf5_group(*args, **kwargs):
"""Load a recarray from columns stored as separate datasets with an
HDF5 group.
Either provide an h5py group as a single positional argument,
or provide two positional arguments giving the HDF5 file path and the
group node path within the file.
Th... | python | def recarray_from_hdf5_group(*args, **kwargs):
"""Load a recarray from columns stored as separate datasets with an
HDF5 group.
Either provide an h5py group as a single positional argument,
or provide two positional arguments giving the HDF5 file path and the
group node path within the file.
Th... | [
"def",
"recarray_from_hdf5_group",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"h5py",
"h5f",
"=",
"None",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"group",
"=",
"args",
"[",
"0",
"]",
"elif",
"len",
"(",
"args",
")",
"==... | Load a recarray from columns stored as separate datasets with an
HDF5 group.
Either provide an h5py group as a single positional argument,
or provide two positional arguments giving the HDF5 file path and the
group node path within the file.
The following optional parameters may be given.
Par... | [
"Load",
"a",
"recarray",
"from",
"columns",
"stored",
"as",
"separate",
"datasets",
"with",
"an",
"HDF5",
"group",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/io/util.py#L55-L146 |
cggh/scikit-allel | allel/io/util.py | recarray_to_hdf5_group | def recarray_to_hdf5_group(ra, parent, name, **kwargs):
"""Write each column in a recarray to a dataset in an HDF5 group.
Parameters
----------
ra : recarray
Numpy recarray to store.
parent : string or h5py group
Parent HDF5 file or group. If a string, will be treated as HDF5 file
... | python | def recarray_to_hdf5_group(ra, parent, name, **kwargs):
"""Write each column in a recarray to a dataset in an HDF5 group.
Parameters
----------
ra : recarray
Numpy recarray to store.
parent : string or h5py group
Parent HDF5 file or group. If a string, will be treated as HDF5 file
... | [
"def",
"recarray_to_hdf5_group",
"(",
"ra",
",",
"parent",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"h5py",
"h5f",
"=",
"None",
"if",
"isinstance",
"(",
"parent",
",",
"str",
")",
":",
"h5f",
"=",
"h5py",
".",
"File",
"(",
"parent",
... | Write each column in a recarray to a dataset in an HDF5 group.
Parameters
----------
ra : recarray
Numpy recarray to store.
parent : string or h5py group
Parent HDF5 file or group. If a string, will be treated as HDF5 file
name.
name : string
Name or path of group to... | [
"Write",
"each",
"column",
"in",
"a",
"recarray",
"to",
"a",
"dataset",
"in",
"an",
"HDF5",
"group",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/io/util.py#L149-L188 |
cggh/scikit-allel | allel/model/ndarray.py | subset | def subset(data, sel0, sel1):
"""Apply selections on first and second axes."""
# check inputs
data = np.asarray(data)
if data.ndim < 2:
raise ValueError('data must have 2 or more dimensions')
sel0 = asarray_ndim(sel0, 1, allow_none=True)
sel1 = asarray_ndim(sel1, 1, allow_none=True)
... | python | def subset(data, sel0, sel1):
"""Apply selections on first and second axes."""
# check inputs
data = np.asarray(data)
if data.ndim < 2:
raise ValueError('data must have 2 or more dimensions')
sel0 = asarray_ndim(sel0, 1, allow_none=True)
sel1 = asarray_ndim(sel1, 1, allow_none=True)
... | [
"def",
"subset",
"(",
"data",
",",
"sel0",
",",
"sel1",
")",
":",
"# check inputs",
"data",
"=",
"np",
".",
"asarray",
"(",
"data",
")",
"if",
"data",
".",
"ndim",
"<",
"2",
":",
"raise",
"ValueError",
"(",
"'data must have 2 or more dimensions'",
")",
"... | Apply selections on first and second axes. | [
"Apply",
"selections",
"on",
"first",
"and",
"second",
"axes",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L43-L69 |
cggh/scikit-allel | allel/model/ndarray.py | NumpyRecArrayWrapper.eval | def eval(self, expression, vm='python'):
"""Evaluate an expression against the table columns.
Parameters
----------
expression : string
Expression to evaluate.
vm : {'numexpr', 'python'}
Virtual machine to use.
Returns
-------
res... | python | def eval(self, expression, vm='python'):
"""Evaluate an expression against the table columns.
Parameters
----------
expression : string
Expression to evaluate.
vm : {'numexpr', 'python'}
Virtual machine to use.
Returns
-------
res... | [
"def",
"eval",
"(",
"self",
",",
"expression",
",",
"vm",
"=",
"'python'",
")",
":",
"if",
"vm",
"==",
"'numexpr'",
":",
"import",
"numexpr",
"as",
"ne",
"return",
"ne",
".",
"evaluate",
"(",
"expression",
",",
"local_dict",
"=",
"self",
")",
"else",
... | Evaluate an expression against the table columns.
Parameters
----------
expression : string
Expression to evaluate.
vm : {'numexpr', 'python'}
Virtual machine to use.
Returns
-------
result : ndarray | [
"Evaluate",
"an",
"expression",
"against",
"the",
"table",
"columns",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L129-L154 |
cggh/scikit-allel | allel/model/ndarray.py | NumpyRecArrayWrapper.query | def query(self, expression, vm='python'):
"""Evaluate expression and then use it to extract rows from the table.
Parameters
----------
expression : string
Expression to evaluate.
vm : {'numexpr', 'python'}
Virtual machine to use.
Returns
... | python | def query(self, expression, vm='python'):
"""Evaluate expression and then use it to extract rows from the table.
Parameters
----------
expression : string
Expression to evaluate.
vm : {'numexpr', 'python'}
Virtual machine to use.
Returns
... | [
"def",
"query",
"(",
"self",
",",
"expression",
",",
"vm",
"=",
"'python'",
")",
":",
"condition",
"=",
"self",
".",
"eval",
"(",
"expression",
",",
"vm",
"=",
"vm",
")",
"return",
"self",
".",
"compress",
"(",
"condition",
")"
] | Evaluate expression and then use it to extract rows from the table.
Parameters
----------
expression : string
Expression to evaluate.
vm : {'numexpr', 'python'}
Virtual machine to use.
Returns
-------
result : structured array | [
"Evaluate",
"expression",
"and",
"then",
"use",
"it",
"to",
"extract",
"rows",
"from",
"the",
"table",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L156-L173 |
cggh/scikit-allel | allel/model/ndarray.py | NumpyRecArrayWrapper.concatenate | def concatenate(self, others):
"""Concatenate arrays."""
if not isinstance(others, (list, tuple)):
others = others,
tup = (self.values,) + tuple(o.values for o in others)
out = np.concatenate(tup, axis=0)
out = type(self)(out)
return out | python | def concatenate(self, others):
"""Concatenate arrays."""
if not isinstance(others, (list, tuple)):
others = others,
tup = (self.values,) + tuple(o.values for o in others)
out = np.concatenate(tup, axis=0)
out = type(self)(out)
return out | [
"def",
"concatenate",
"(",
"self",
",",
"others",
")",
":",
"if",
"not",
"isinstance",
"(",
"others",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"others",
"=",
"others",
",",
"tup",
"=",
"(",
"self",
".",
"values",
",",
")",
"+",
"tuple",
"("... | Concatenate arrays. | [
"Concatenate",
"arrays",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L192-L199 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.fill_masked | def fill_masked(self, value=-1, copy=True):
"""Fill masked genotype calls with a given value.
Parameters
----------
value : int, optional
The fill value.
copy : bool, optional
If False, modify the array in place.
Returns
-------
g... | python | def fill_masked(self, value=-1, copy=True):
"""Fill masked genotype calls with a given value.
Parameters
----------
value : int, optional
The fill value.
copy : bool, optional
If False, modify the array in place.
Returns
-------
g... | [
"def",
"fill_masked",
"(",
"self",
",",
"value",
"=",
"-",
"1",
",",
"copy",
"=",
"True",
")",
":",
"if",
"self",
".",
"mask",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'no mask is set'",
")",
"# apply the mask",
"data",
"=",
"np",
".",
"array",
... | Fill masked genotype calls with a given value.
Parameters
----------
value : int, optional
The fill value.
copy : bool, optional
If False, modify the array in place.
Returns
-------
g : GenotypeArray
Examples
--------
... | [
"Fill",
"masked",
"genotype",
"calls",
"with",
"a",
"given",
"value",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L332-L380 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.is_called | def is_called(self):
"""Find non-missing genotype calls.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype call matches the
condition.
Examples
--------
>>> import allel
... | python | def is_called(self):
"""Find non-missing genotype calls.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype call matches the
condition.
Examples
--------
>>> import allel
... | [
"def",
"is_called",
"(",
"self",
")",
":",
"out",
"=",
"np",
".",
"all",
"(",
"self",
".",
"values",
">=",
"0",
",",
"axis",
"=",
"-",
"1",
")",
"# handle mask",
"if",
"self",
".",
"mask",
"is",
"not",
"None",
":",
"out",
"&=",
"~",
"self",
"."... | Find non-missing genotype calls.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype call matches the
condition.
Examples
--------
>>> import allel
>>> g = allel.GenotypeArray(... | [
"Find",
"non",
"-",
"missing",
"genotype",
"calls",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L382-L417 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.is_missing | def is_missing(self):
"""Find missing genotype calls.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype call matches the
condition.
Examples
--------
>>> import allel
... | python | def is_missing(self):
"""Find missing genotype calls.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype call matches the
condition.
Examples
--------
>>> import allel
... | [
"def",
"is_missing",
"(",
"self",
")",
":",
"out",
"=",
"np",
".",
"any",
"(",
"self",
".",
"values",
"<",
"0",
",",
"axis",
"=",
"-",
"1",
")",
"# handle mask",
"if",
"self",
".",
"mask",
"is",
"not",
"None",
":",
"out",
"|=",
"self",
".",
"ma... | Find missing genotype calls.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype call matches the
condition.
Examples
--------
>>> import allel
>>> g = allel.GenotypeArray([[[0... | [
"Find",
"missing",
"genotype",
"calls",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L419-L454 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.is_hom | def is_hom(self, allele=None):
"""Find genotype calls that are homozygous.
Parameters
----------
allele : int, optional
Allele index.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the ... | python | def is_hom(self, allele=None):
"""Find genotype calls that are homozygous.
Parameters
----------
allele : int, optional
Allele index.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the ... | [
"def",
"is_hom",
"(",
"self",
",",
"allele",
"=",
"None",
")",
":",
"if",
"allele",
"is",
"None",
":",
"allele1",
"=",
"self",
".",
"values",
"[",
"...",
",",
"0",
",",
"np",
".",
"newaxis",
"]",
"other_alleles",
"=",
"self",
".",
"values",
"[",
... | Find genotype calls that are homozygous.
Parameters
----------
allele : int, optional
Allele index.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype call matches the
cond... | [
"Find",
"genotype",
"calls",
"that",
"are",
"homozygous",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L456-L506 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.is_hom_alt | def is_hom_alt(self):
"""Find genotype calls that are homozygous for any alternate (i.e.,
non-reference) allele.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype call matches the
condition.
... | python | def is_hom_alt(self):
"""Find genotype calls that are homozygous for any alternate (i.e.,
non-reference) allele.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype call matches the
condition.
... | [
"def",
"is_hom_alt",
"(",
"self",
")",
":",
"allele1",
"=",
"self",
".",
"values",
"[",
"...",
",",
"0",
",",
"np",
".",
"newaxis",
"]",
"other_alleles",
"=",
"self",
".",
"values",
"[",
"...",
",",
"1",
":",
"]",
"tmp",
"=",
"(",
"allele1",
">",... | Find genotype calls that are homozygous for any alternate (i.e.,
non-reference) allele.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype call matches the
condition.
Examples
--------... | [
"Find",
"genotype",
"calls",
"that",
"are",
"homozygous",
"for",
"any",
"alternate",
"(",
"i",
".",
"e",
".",
"non",
"-",
"reference",
")",
"allele",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L539-L578 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.is_het | def is_het(self, allele=None):
"""Find genotype calls that are heterozygous.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype call matches the
condition.
allele : int, optional
He... | python | def is_het(self, allele=None):
"""Find genotype calls that are heterozygous.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype call matches the
condition.
allele : int, optional
He... | [
"def",
"is_het",
"(",
"self",
",",
"allele",
"=",
"None",
")",
":",
"allele1",
"=",
"self",
".",
"values",
"[",
"...",
",",
"0",
",",
"np",
".",
"newaxis",
"]",
"# type: np.ndarray",
"other_alleles",
"=",
"self",
".",
"values",
"[",
"...",
",",
"1",
... | Find genotype calls that are heterozygous.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype call matches the
condition.
allele : int, optional
Heterozygous allele.
Examples
... | [
"Find",
"genotype",
"calls",
"that",
"are",
"heterozygous",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L580-L625 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.is_call | def is_call(self, call):
"""Locate genotypes with a given call.
Parameters
----------
call : array_like, int, shape (ploidy,)
The genotype call to find.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elemen... | python | def is_call(self, call):
"""Locate genotypes with a given call.
Parameters
----------
call : array_like, int, shape (ploidy,)
The genotype call to find.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elemen... | [
"def",
"is_call",
"(",
"self",
",",
"call",
")",
":",
"# guard conditions",
"if",
"not",
"len",
"(",
"call",
")",
"==",
"self",
".",
"shape",
"[",
"-",
"1",
"]",
":",
"raise",
"ValueError",
"(",
"'invalid call ploidy: %s'",
",",
"repr",
"(",
"call",
")... | Locate genotypes with a given call.
Parameters
----------
call : array_like, int, shape (ploidy,)
The genotype call to find.
Returns
-------
out : ndarray, bool, shape (n_variants, n_samples)
Array where elements are True if the genotype is `call... | [
"Locate",
"genotypes",
"with",
"a",
"given",
"call",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L627-L674 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.count_called | def count_called(self, axis=None):
"""Count called genotypes.
Parameters
----------
axis : int, optional
Axis over which to count, or None to perform overall count.
"""
b = self.is_called()
return np.sum(b, axis=axis) | python | def count_called(self, axis=None):
"""Count called genotypes.
Parameters
----------
axis : int, optional
Axis over which to count, or None to perform overall count.
"""
b = self.is_called()
return np.sum(b, axis=axis) | [
"def",
"count_called",
"(",
"self",
",",
"axis",
"=",
"None",
")",
":",
"b",
"=",
"self",
".",
"is_called",
"(",
")",
"return",
"np",
".",
"sum",
"(",
"b",
",",
"axis",
"=",
"axis",
")"
] | Count called genotypes.
Parameters
----------
axis : int, optional
Axis over which to count, or None to perform overall count. | [
"Count",
"called",
"genotypes",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L676-L686 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.count_missing | def count_missing(self, axis=None):
"""Count missing genotypes.
Parameters
----------
axis : int, optional
Axis over which to count, or None to perform overall count.
"""
b = self.is_missing()
return np.sum(b, axis=axis) | python | def count_missing(self, axis=None):
"""Count missing genotypes.
Parameters
----------
axis : int, optional
Axis over which to count, or None to perform overall count.
"""
b = self.is_missing()
return np.sum(b, axis=axis) | [
"def",
"count_missing",
"(",
"self",
",",
"axis",
"=",
"None",
")",
":",
"b",
"=",
"self",
".",
"is_missing",
"(",
")",
"return",
"np",
".",
"sum",
"(",
"b",
",",
"axis",
"=",
"axis",
")"
] | Count missing genotypes.
Parameters
----------
axis : int, optional
Axis over which to count, or None to perform overall count. | [
"Count",
"missing",
"genotypes",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L688-L698 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.count_hom | def count_hom(self, allele=None, axis=None):
"""Count homozygous genotypes.
Parameters
----------
allele : int, optional
Allele index.
axis : int, optional
Axis over which to count, or None to perform overall count.
"""
b = self.is_hom(al... | python | def count_hom(self, allele=None, axis=None):
"""Count homozygous genotypes.
Parameters
----------
allele : int, optional
Allele index.
axis : int, optional
Axis over which to count, or None to perform overall count.
"""
b = self.is_hom(al... | [
"def",
"count_hom",
"(",
"self",
",",
"allele",
"=",
"None",
",",
"axis",
"=",
"None",
")",
":",
"b",
"=",
"self",
".",
"is_hom",
"(",
"allele",
"=",
"allele",
")",
"return",
"np",
".",
"sum",
"(",
"b",
",",
"axis",
"=",
"axis",
")"
] | Count homozygous genotypes.
Parameters
----------
allele : int, optional
Allele index.
axis : int, optional
Axis over which to count, or None to perform overall count. | [
"Count",
"homozygous",
"genotypes",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L700-L712 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.count_hom_ref | def count_hom_ref(self, axis=None):
"""Count homozygous reference genotypes.
Parameters
----------
axis : int, optional
Axis over which to count, or None to perform overall count.
"""
b = self.is_hom_ref()
return np.sum(b, axis=axis) | python | def count_hom_ref(self, axis=None):
"""Count homozygous reference genotypes.
Parameters
----------
axis : int, optional
Axis over which to count, or None to perform overall count.
"""
b = self.is_hom_ref()
return np.sum(b, axis=axis) | [
"def",
"count_hom_ref",
"(",
"self",
",",
"axis",
"=",
"None",
")",
":",
"b",
"=",
"self",
".",
"is_hom_ref",
"(",
")",
"return",
"np",
".",
"sum",
"(",
"b",
",",
"axis",
"=",
"axis",
")"
] | Count homozygous reference genotypes.
Parameters
----------
axis : int, optional
Axis over which to count, or None to perform overall count. | [
"Count",
"homozygous",
"reference",
"genotypes",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L714-L724 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.count_hom_alt | def count_hom_alt(self, axis=None):
"""Count homozygous alternate genotypes.
Parameters
----------
axis : int, optional
Axis over which to count, or None to perform overall count.
"""
b = self.is_hom_alt()
return np.sum(b, axis=axis) | python | def count_hom_alt(self, axis=None):
"""Count homozygous alternate genotypes.
Parameters
----------
axis : int, optional
Axis over which to count, or None to perform overall count.
"""
b = self.is_hom_alt()
return np.sum(b, axis=axis) | [
"def",
"count_hom_alt",
"(",
"self",
",",
"axis",
"=",
"None",
")",
":",
"b",
"=",
"self",
".",
"is_hom_alt",
"(",
")",
"return",
"np",
".",
"sum",
"(",
"b",
",",
"axis",
"=",
"axis",
")"
] | Count homozygous alternate genotypes.
Parameters
----------
axis : int, optional
Axis over which to count, or None to perform overall count. | [
"Count",
"homozygous",
"alternate",
"genotypes",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L726-L736 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.count_het | def count_het(self, allele=None, axis=None):
"""Count heterozygous genotypes.
Parameters
----------
allele : int, optional
Allele index.
axis : int, optional
Axis over which to count, or None to perform overall count.
"""
b = self.is_het(... | python | def count_het(self, allele=None, axis=None):
"""Count heterozygous genotypes.
Parameters
----------
allele : int, optional
Allele index.
axis : int, optional
Axis over which to count, or None to perform overall count.
"""
b = self.is_het(... | [
"def",
"count_het",
"(",
"self",
",",
"allele",
"=",
"None",
",",
"axis",
"=",
"None",
")",
":",
"b",
"=",
"self",
".",
"is_het",
"(",
"allele",
"=",
"allele",
")",
"return",
"np",
".",
"sum",
"(",
"b",
",",
"axis",
"=",
"axis",
")"
] | Count heterozygous genotypes.
Parameters
----------
allele : int, optional
Allele index.
axis : int, optional
Axis over which to count, or None to perform overall count. | [
"Count",
"heterozygous",
"genotypes",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L738-L750 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.count_call | def count_call(self, call, axis=None):
"""Count genotypes with a given call.
Parameters
----------
call : array_like, int, shape (ploidy,)
The genotype call to find.
axis : int, optional
Axis over which to count, or None to perform overall count.
... | python | def count_call(self, call, axis=None):
"""Count genotypes with a given call.
Parameters
----------
call : array_like, int, shape (ploidy,)
The genotype call to find.
axis : int, optional
Axis over which to count, or None to perform overall count.
... | [
"def",
"count_call",
"(",
"self",
",",
"call",
",",
"axis",
"=",
"None",
")",
":",
"b",
"=",
"self",
".",
"is_call",
"(",
"call",
"=",
"call",
")",
"return",
"np",
".",
"sum",
"(",
"b",
",",
"axis",
"=",
"axis",
")"
] | Count genotypes with a given call.
Parameters
----------
call : array_like, int, shape (ploidy,)
The genotype call to find.
axis : int, optional
Axis over which to count, or None to perform overall count. | [
"Count",
"genotypes",
"with",
"a",
"given",
"call",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L752-L764 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.to_n_ref | def to_n_ref(self, fill=0, dtype='i1'):
"""Transform each genotype call into the number of
reference alleles.
Parameters
----------
fill : int, optional
Use this value to represent missing calls.
dtype : dtype, optional
Output dtype.
Retu... | python | def to_n_ref(self, fill=0, dtype='i1'):
"""Transform each genotype call into the number of
reference alleles.
Parameters
----------
fill : int, optional
Use this value to represent missing calls.
dtype : dtype, optional
Output dtype.
Retu... | [
"def",
"to_n_ref",
"(",
"self",
",",
"fill",
"=",
"0",
",",
"dtype",
"=",
"'i1'",
")",
":",
"# count number of alternate alleles",
"out",
"=",
"np",
".",
"empty",
"(",
"self",
".",
"shape",
"[",
":",
"-",
"1",
"]",
",",
"dtype",
"=",
"dtype",
")",
... | Transform each genotype call into the number of
reference alleles.
Parameters
----------
fill : int, optional
Use this value to represent missing calls.
dtype : dtype, optional
Output dtype.
Returns
-------
out : ndarray, int8, sh... | [
"Transform",
"each",
"genotype",
"call",
"into",
"the",
"number",
"of",
"reference",
"alleles",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L766-L825 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.to_allele_counts | def to_allele_counts(self, max_allele=None, dtype='u1'):
"""Transform genotype calls into allele counts per call.
Parameters
----------
max_allele : int, optional
Highest allele index. Provide this value to speed up computation.
dtype : dtype, optional
Ou... | python | def to_allele_counts(self, max_allele=None, dtype='u1'):
"""Transform genotype calls into allele counts per call.
Parameters
----------
max_allele : int, optional
Highest allele index. Provide this value to speed up computation.
dtype : dtype, optional
Ou... | [
"def",
"to_allele_counts",
"(",
"self",
",",
"max_allele",
"=",
"None",
",",
"dtype",
"=",
"'u1'",
")",
":",
"# determine alleles to count",
"if",
"max_allele",
"is",
"None",
":",
"max_allele",
"=",
"self",
".",
"max",
"(",
")",
"alleles",
"=",
"list",
"("... | Transform genotype calls into allele counts per call.
Parameters
----------
max_allele : int, optional
Highest allele index. Provide this value to speed up computation.
dtype : dtype, optional
Output dtype.
Returns
-------
out : ndarray, ... | [
"Transform",
"genotype",
"calls",
"into",
"allele",
"counts",
"per",
"call",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L892-L950 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.to_gt | def to_gt(self, max_allele=None):
"""Convert genotype calls to VCF-style string representation.
Returns
-------
gt : ndarray, string, shape (n_variants, n_samples)
Examples
--------
>>> import allel
>>> g = allel.GenotypeArray([[[0, 0], [0, 1]],
... | python | def to_gt(self, max_allele=None):
"""Convert genotype calls to VCF-style string representation.
Returns
-------
gt : ndarray, string, shape (n_variants, n_samples)
Examples
--------
>>> import allel
>>> g = allel.GenotypeArray([[[0, 0], [0, 1]],
... | [
"def",
"to_gt",
"(",
"self",
",",
"max_allele",
"=",
"None",
")",
":",
"# how many characters needed per allele call?",
"if",
"max_allele",
"is",
"None",
":",
"max_allele",
"=",
"np",
".",
"max",
"(",
"self",
")",
"if",
"max_allele",
"<=",
"0",
":",
"max_all... | Convert genotype calls to VCF-style string representation.
Returns
-------
gt : ndarray, string, shape (n_variants, n_samples)
Examples
--------
>>> import allel
>>> g = allel.GenotypeArray([[[0, 0], [0, 1]],
... [[0, 2], [1, 1]... | [
"Convert",
"genotype",
"calls",
"to",
"VCF",
"-",
"style",
"string",
"representation",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L952-L1025 |
cggh/scikit-allel | allel/model/ndarray.py | Genotypes.map_alleles | def map_alleles(self, mapping, copy=True):
"""Transform alleles via a mapping.
Parameters
----------
mapping : ndarray, int8, shape (n_variants, max_allele)
An array defining the allele mapping for each variant.
copy : bool, optional
If True, return a new... | python | def map_alleles(self, mapping, copy=True):
"""Transform alleles via a mapping.
Parameters
----------
mapping : ndarray, int8, shape (n_variants, max_allele)
An array defining the allele mapping for each variant.
copy : bool, optional
If True, return a new... | [
"def",
"map_alleles",
"(",
"self",
",",
"mapping",
",",
"copy",
"=",
"True",
")",
":",
"h",
"=",
"self",
".",
"to_haplotypes",
"(",
")",
"hm",
"=",
"h",
".",
"map_alleles",
"(",
"mapping",
",",
"copy",
"=",
"copy",
")",
"if",
"self",
".",
"ndim",
... | Transform alleles via a mapping.
Parameters
----------
mapping : ndarray, int8, shape (n_variants, max_allele)
An array defining the allele mapping for each variant.
copy : bool, optional
If True, return a new array; if False, apply mapping in place
(... | [
"Transform",
"alleles",
"via",
"a",
"mapping",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1036-L1099 |
cggh/scikit-allel | allel/model/ndarray.py | GenotypeArray.to_packed | def to_packed(self, boundscheck=True):
"""Pack diploid genotypes into a single byte for each genotype,
using the left-most 4 bits for the first allele and the right-most 4
bits for the second allele. Allows single byte encoding of diploid
genotypes for variants with up to 15 alleles.
... | python | def to_packed(self, boundscheck=True):
"""Pack diploid genotypes into a single byte for each genotype,
using the left-most 4 bits for the first allele and the right-most 4
bits for the second allele. Allows single byte encoding of diploid
genotypes for variants with up to 15 alleles.
... | [
"def",
"to_packed",
"(",
"self",
",",
"boundscheck",
"=",
"True",
")",
":",
"check_ploidy",
"(",
"self",
".",
"ploidy",
",",
"2",
")",
"if",
"boundscheck",
":",
"amx",
"=",
"self",
".",
"max",
"(",
")",
"if",
"amx",
">",
"14",
":",
"raise",
"ValueE... | Pack diploid genotypes into a single byte for each genotype,
using the left-most 4 bits for the first allele and the right-most 4
bits for the second allele. Allows single byte encoding of diploid
genotypes for variants with up to 15 alleles.
Parameters
----------
bounds... | [
"Pack",
"diploid",
"genotypes",
"into",
"a",
"single",
"byte",
"for",
"each",
"genotype",
"using",
"the",
"left",
"-",
"most",
"4",
"bits",
"for",
"the",
"first",
"allele",
"and",
"the",
"right",
"-",
"most",
"4",
"bits",
"for",
"the",
"second",
"allele"... | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1553-L1602 |
cggh/scikit-allel | allel/model/ndarray.py | GenotypeArray.from_packed | def from_packed(cls, packed):
"""Unpack diploid genotypes that have been bit-packed into single
bytes.
Parameters
----------
packed : ndarray, uint8, shape (n_variants, n_samples)
Bit-packed diploid genotype array.
Returns
-------
g : Genotyp... | python | def from_packed(cls, packed):
"""Unpack diploid genotypes that have been bit-packed into single
bytes.
Parameters
----------
packed : ndarray, uint8, shape (n_variants, n_samples)
Bit-packed diploid genotype array.
Returns
-------
g : Genotyp... | [
"def",
"from_packed",
"(",
"cls",
",",
"packed",
")",
":",
"# check arguments",
"packed",
"=",
"np",
".",
"asarray",
"(",
"packed",
")",
"check_ndim",
"(",
"packed",
",",
"2",
")",
"check_dtype",
"(",
"packed",
",",
"'u1'",
")",
"packed",
"=",
"memoryvie... | Unpack diploid genotypes that have been bit-packed into single
bytes.
Parameters
----------
packed : ndarray, uint8, shape (n_variants, n_samples)
Bit-packed diploid genotype array.
Returns
-------
g : GenotypeArray, shape (n_variants, n_samples, 2)
... | [
"Unpack",
"diploid",
"genotypes",
"that",
"have",
"been",
"bit",
"-",
"packed",
"into",
"single",
"bytes",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1605-L1642 |
cggh/scikit-allel | allel/model/ndarray.py | GenotypeArray.to_sparse | def to_sparse(self, format='csr', **kwargs):
"""Convert into a sparse matrix.
Parameters
----------
format : {'coo', 'csc', 'csr', 'dia', 'dok', 'lil'}
Sparse matrix format.
kwargs : keyword arguments
Passed through to sparse matrix constructor.
... | python | def to_sparse(self, format='csr', **kwargs):
"""Convert into a sparse matrix.
Parameters
----------
format : {'coo', 'csc', 'csr', 'dia', 'dok', 'lil'}
Sparse matrix format.
kwargs : keyword arguments
Passed through to sparse matrix constructor.
... | [
"def",
"to_sparse",
"(",
"self",
",",
"format",
"=",
"'csr'",
",",
"*",
"*",
"kwargs",
")",
":",
"h",
"=",
"self",
".",
"to_haplotypes",
"(",
")",
"m",
"=",
"h",
".",
"to_sparse",
"(",
"format",
"=",
"format",
",",
"*",
"*",
"kwargs",
")",
"retur... | Convert into a sparse matrix.
Parameters
----------
format : {'coo', 'csc', 'csr', 'dia', 'dok', 'lil'}
Sparse matrix format.
kwargs : keyword arguments
Passed through to sparse matrix constructor.
Returns
-------
m : scipy.sparse.spmatri... | [
"Convert",
"into",
"a",
"sparse",
"matrix",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1645-L1688 |
cggh/scikit-allel | allel/model/ndarray.py | GenotypeArray.from_sparse | def from_sparse(m, ploidy, order=None, out=None):
"""Construct a genotype array from a sparse matrix.
Parameters
----------
m : scipy.sparse.spmatrix
Sparse matrix
ploidy : int
The sample ploidy.
order : {'C', 'F'}, optional
Whether to... | python | def from_sparse(m, ploidy, order=None, out=None):
"""Construct a genotype array from a sparse matrix.
Parameters
----------
m : scipy.sparse.spmatrix
Sparse matrix
ploidy : int
The sample ploidy.
order : {'C', 'F'}, optional
Whether to... | [
"def",
"from_sparse",
"(",
"m",
",",
"ploidy",
",",
"order",
"=",
"None",
",",
"out",
"=",
"None",
")",
":",
"h",
"=",
"HaplotypeArray",
".",
"from_sparse",
"(",
"m",
",",
"order",
"=",
"order",
",",
"out",
"=",
"out",
")",
"g",
"=",
"h",
".",
... | Construct a genotype array from a sparse matrix.
Parameters
----------
m : scipy.sparse.spmatrix
Sparse matrix
ploidy : int
The sample ploidy.
order : {'C', 'F'}, optional
Whether to store data in C (row-major) or Fortran (column-major)
... | [
"Construct",
"a",
"genotype",
"array",
"from",
"a",
"sparse",
"matrix",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1691-L1733 |
cggh/scikit-allel | allel/model/ndarray.py | GenotypeArray.haploidify_samples | def haploidify_samples(self):
"""Construct a pseudo-haplotype for each sample by randomly
selecting an allele from each genotype call.
Returns
-------
h : HaplotypeArray
Notes
-----
If a mask has been set, it is ignored by this function.
Example... | python | def haploidify_samples(self):
"""Construct a pseudo-haplotype for each sample by randomly
selecting an allele from each genotype call.
Returns
-------
h : HaplotypeArray
Notes
-----
If a mask has been set, it is ignored by this function.
Example... | [
"def",
"haploidify_samples",
"(",
"self",
")",
":",
"# N.B., this implementation is obscure and uses more memory than",
"# necessary, TODO review",
"# define the range of possible indices, e.g., diploid => (0, 1)",
"index_range",
"=",
"np",
".",
"arange",
"(",
"0",
",",
"self",
"... | Construct a pseudo-haplotype for each sample by randomly
selecting an allele from each genotype call.
Returns
-------
h : HaplotypeArray
Notes
-----
If a mask has been set, it is ignored by this function.
Examples
--------
>>> import al... | [
"Construct",
"a",
"pseudo",
"-",
"haplotype",
"for",
"each",
"sample",
"by",
"randomly",
"selecting",
"an",
"allele",
"from",
"each",
"genotype",
"call",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1735-L1797 |
cggh/scikit-allel | allel/model/ndarray.py | GenotypeArray.count_alleles | def count_alleles(self, max_allele=None, subpop=None):
"""Count the number of calls of each allele per variant.
Parameters
----------
max_allele : int, optional
The highest allele index to count. Alleles above this will be
ignored.
subpop : sequence of in... | python | def count_alleles(self, max_allele=None, subpop=None):
"""Count the number of calls of each allele per variant.
Parameters
----------
max_allele : int, optional
The highest allele index to count. Alleles above this will be
ignored.
subpop : sequence of in... | [
"def",
"count_alleles",
"(",
"self",
",",
"max_allele",
"=",
"None",
",",
"subpop",
"=",
"None",
")",
":",
"# check inputs",
"subpop",
"=",
"_normalize_subpop_arg",
"(",
"subpop",
",",
"self",
".",
"shape",
"[",
"1",
"]",
")",
"# determine alleles to count",
... | Count the number of calls of each allele per variant.
Parameters
----------
max_allele : int, optional
The highest allele index to count. Alleles above this will be
ignored.
subpop : sequence of ints, optional
Indices of samples to include in count.
... | [
"Count",
"the",
"number",
"of",
"calls",
"of",
"each",
"allele",
"per",
"variant",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1799-L1853 |
cggh/scikit-allel | allel/model/ndarray.py | GenotypeArray.count_alleles_subpops | def count_alleles_subpops(self, subpops, max_allele=None):
"""Count alleles for multiple subpopulations simultaneously.
Parameters
----------
subpops : dict (string -> sequence of ints)
Mapping of subpopulation names to sample indices.
max_allele : int, optional
... | python | def count_alleles_subpops(self, subpops, max_allele=None):
"""Count alleles for multiple subpopulations simultaneously.
Parameters
----------
subpops : dict (string -> sequence of ints)
Mapping of subpopulation names to sample indices.
max_allele : int, optional
... | [
"def",
"count_alleles_subpops",
"(",
"self",
",",
"subpops",
",",
"max_allele",
"=",
"None",
")",
":",
"if",
"max_allele",
"is",
"None",
":",
"max_allele",
"=",
"self",
".",
"max",
"(",
")",
"out",
"=",
"{",
"name",
":",
"self",
".",
"count_alleles",
"... | Count alleles for multiple subpopulations simultaneously.
Parameters
----------
subpops : dict (string -> sequence of ints)
Mapping of subpopulation names to sample indices.
max_allele : int, optional
The highest allele index to count. Alleles above this will be
... | [
"Count",
"alleles",
"for",
"multiple",
"subpopulations",
"simultaneously",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1855-L1879 |
cggh/scikit-allel | allel/model/ndarray.py | HaplotypeArray.compress | def compress(self, condition, axis=0, out=None):
"""Return selected slices of an array along given axis.
Parameters
----------
condition : array_like, bool
Array that selects which entries to return. N.B., if len(condition)
is less than the size of the given axis... | python | def compress(self, condition, axis=0, out=None):
"""Return selected slices of an array along given axis.
Parameters
----------
condition : array_like, bool
Array that selects which entries to return. N.B., if len(condition)
is less than the size of the given axis... | [
"def",
"compress",
"(",
"self",
",",
"condition",
",",
"axis",
"=",
"0",
",",
"out",
"=",
"None",
")",
":",
"return",
"compress_haplotype_array",
"(",
"self",
",",
"condition",
",",
"axis",
"=",
"axis",
",",
"cls",
"=",
"type",
"(",
"self",
")",
",",... | Return selected slices of an array along given axis.
Parameters
----------
condition : array_like, bool
Array that selects which entries to return. N.B., if len(condition)
is less than the size of the given axis, then output is truncated to the length
of the ... | [
"Return",
"selected",
"slices",
"of",
"an",
"array",
"along",
"given",
"axis",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1995-L2034 |
cggh/scikit-allel | allel/model/ndarray.py | HaplotypeArray.take | def take(self, indices, axis=0, out=None, mode='raise'):
"""Take elements from an array along an axis.
This function does the same thing as "fancy" indexing (indexing arrays
using arrays); however, it can be easier to use if you need elements
along a given axis.
Parameters
... | python | def take(self, indices, axis=0, out=None, mode='raise'):
"""Take elements from an array along an axis.
This function does the same thing as "fancy" indexing (indexing arrays
using arrays); however, it can be easier to use if you need elements
along a given axis.
Parameters
... | [
"def",
"take",
"(",
"self",
",",
"indices",
",",
"axis",
"=",
"0",
",",
"out",
"=",
"None",
",",
"mode",
"=",
"'raise'",
")",
":",
"return",
"take_haplotype_array",
"(",
"self",
",",
"indices",
",",
"axis",
"=",
"axis",
",",
"cls",
"=",
"type",
"("... | Take elements from an array along an axis.
This function does the same thing as "fancy" indexing (indexing arrays
using arrays); however, it can be easier to use if you need elements
along a given axis.
Parameters
----------
indices : array_like
The indices ... | [
"Take",
"elements",
"from",
"an",
"array",
"along",
"an",
"axis",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2036-L2086 |
cggh/scikit-allel | allel/model/ndarray.py | HaplotypeArray.subset | def subset(self, sel0=None, sel1=None):
"""Make a sub-selection of variants and haplotypes.
Parameters
----------
sel0 : array_like
Boolean array or array of indices selecting variants.
sel1 : array_like
Boolean array or array of indices selecting haploty... | python | def subset(self, sel0=None, sel1=None):
"""Make a sub-selection of variants and haplotypes.
Parameters
----------
sel0 : array_like
Boolean array or array of indices selecting variants.
sel1 : array_like
Boolean array or array of indices selecting haploty... | [
"def",
"subset",
"(",
"self",
",",
"sel0",
"=",
"None",
",",
"sel1",
"=",
"None",
")",
":",
"return",
"subset_haplotype_array",
"(",
"self",
",",
"sel0",
",",
"sel1",
",",
"cls",
"=",
"type",
"(",
"self",
")",
",",
"subset",
"=",
"subset",
")"
] | Make a sub-selection of variants and haplotypes.
Parameters
----------
sel0 : array_like
Boolean array or array of indices selecting variants.
sel1 : array_like
Boolean array or array of indices selecting haplotypes.
Returns
-------
out :... | [
"Make",
"a",
"sub",
"-",
"selection",
"of",
"variants",
"and",
"haplotypes",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2088-L2107 |
cggh/scikit-allel | allel/model/ndarray.py | HaplotypeArray.concatenate | def concatenate(self, others, axis=0):
"""Join a sequence of arrays along an existing axis.
Parameters
----------
others : sequence of array_like
The arrays must have the same shape, except in the dimension
corresponding to `axis` (the first, by default).
... | python | def concatenate(self, others, axis=0):
"""Join a sequence of arrays along an existing axis.
Parameters
----------
others : sequence of array_like
The arrays must have the same shape, except in the dimension
corresponding to `axis` (the first, by default).
... | [
"def",
"concatenate",
"(",
"self",
",",
"others",
",",
"axis",
"=",
"0",
")",
":",
"return",
"concatenate_haplotype_array",
"(",
"self",
",",
"others",
",",
"axis",
"=",
"axis",
",",
"cls",
"=",
"type",
"(",
"self",
")",
",",
"concatenate",
"=",
"np",
... | Join a sequence of arrays along an existing axis.
Parameters
----------
others : sequence of array_like
The arrays must have the same shape, except in the dimension
corresponding to `axis` (the first, by default).
axis : int, optional
The axis along w... | [
"Join",
"a",
"sequence",
"of",
"arrays",
"along",
"an",
"existing",
"axis",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2109-L2147 |
cggh/scikit-allel | allel/model/ndarray.py | HaplotypeArray.to_genotypes | def to_genotypes(self, ploidy, copy=False):
"""Reshape a haplotype array to view it as genotypes by restoring the
ploidy dimension.
Parameters
----------
ploidy : int
The sample ploidy.
copy : bool, optional
If True, make a copy of data.
... | python | def to_genotypes(self, ploidy, copy=False):
"""Reshape a haplotype array to view it as genotypes by restoring the
ploidy dimension.
Parameters
----------
ploidy : int
The sample ploidy.
copy : bool, optional
If True, make a copy of data.
... | [
"def",
"to_genotypes",
"(",
"self",
",",
"ploidy",
",",
"copy",
"=",
"False",
")",
":",
"# check ploidy is compatible",
"if",
"(",
"self",
".",
"shape",
"[",
"1",
"]",
"%",
"ploidy",
")",
">",
"0",
":",
"raise",
"ValueError",
"(",
"'incompatible ploidy'",
... | Reshape a haplotype array to view it as genotypes by restoring the
ploidy dimension.
Parameters
----------
ploidy : int
The sample ploidy.
copy : bool, optional
If True, make a copy of data.
Returns
-------
g : ndarray, int, shape... | [
"Reshape",
"a",
"haplotype",
"array",
"to",
"view",
"it",
"as",
"genotypes",
"by",
"restoring",
"the",
"ploidy",
"dimension",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2202-L2246 |
cggh/scikit-allel | allel/model/ndarray.py | HaplotypeArray.to_sparse | def to_sparse(self, format='csr', **kwargs):
"""Convert into a sparse matrix.
Parameters
----------
format : {'coo', 'csc', 'csr', 'dia', 'dok', 'lil'}
Sparse matrix format.
kwargs : keyword arguments
Passed through to sparse matrix constructor.
... | python | def to_sparse(self, format='csr', **kwargs):
"""Convert into a sparse matrix.
Parameters
----------
format : {'coo', 'csc', 'csr', 'dia', 'dok', 'lil'}
Sparse matrix format.
kwargs : keyword arguments
Passed through to sparse matrix constructor.
... | [
"def",
"to_sparse",
"(",
"self",
",",
"format",
"=",
"'csr'",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"scipy",
".",
"sparse",
"# check arguments",
"f",
"=",
"{",
"'bsr'",
":",
"scipy",
".",
"sparse",
".",
"bsr_matrix",
",",
"'coo'",
":",
"scipy",
... | Convert into a sparse matrix.
Parameters
----------
format : {'coo', 'csc', 'csr', 'dia', 'dok', 'lil'}
Sparse matrix format.
kwargs : keyword arguments
Passed through to sparse matrix constructor.
Returns
-------
m : scipy.sparse.spmatri... | [
"Convert",
"into",
"a",
"sparse",
"matrix",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2249-L2303 |
cggh/scikit-allel | allel/model/ndarray.py | HaplotypeArray.from_sparse | def from_sparse(m, order=None, out=None):
"""Construct a haplotype array from a sparse matrix.
Parameters
----------
m : scipy.sparse.spmatrix
Sparse matrix
order : {'C', 'F'}, optional
Whether to store data in C (row-major) or Fortran (column-major)
... | python | def from_sparse(m, order=None, out=None):
"""Construct a haplotype array from a sparse matrix.
Parameters
----------
m : scipy.sparse.spmatrix
Sparse matrix
order : {'C', 'F'}, optional
Whether to store data in C (row-major) or Fortran (column-major)
... | [
"def",
"from_sparse",
"(",
"m",
",",
"order",
"=",
"None",
",",
"out",
"=",
"None",
")",
":",
"import",
"scipy",
".",
"sparse",
"# check arguments",
"if",
"not",
"scipy",
".",
"sparse",
".",
"isspmatrix",
"(",
"m",
")",
":",
"raise",
"ValueError",
"(",... | Construct a haplotype array from a sparse matrix.
Parameters
----------
m : scipy.sparse.spmatrix
Sparse matrix
order : {'C', 'F'}, optional
Whether to store data in C (row-major) or Fortran (column-major)
order in memory.
out : ndarray, shape... | [
"Construct",
"a",
"haplotype",
"array",
"from",
"a",
"sparse",
"matrix",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2306-L2356 |
cggh/scikit-allel | allel/model/ndarray.py | HaplotypeArray.count_alleles | def count_alleles(self, max_allele=None, subpop=None):
"""Count the number of calls of each allele per variant.
Parameters
----------
max_allele : int, optional
The highest allele index to count. Alleles greater than this
index will be ignored.
subpop : a... | python | def count_alleles(self, max_allele=None, subpop=None):
"""Count the number of calls of each allele per variant.
Parameters
----------
max_allele : int, optional
The highest allele index to count. Alleles greater than this
index will be ignored.
subpop : a... | [
"def",
"count_alleles",
"(",
"self",
",",
"max_allele",
"=",
"None",
",",
"subpop",
"=",
"None",
")",
":",
"# check inputs",
"subpop",
"=",
"_normalize_subpop_arg",
"(",
"subpop",
",",
"self",
".",
"shape",
"[",
"1",
"]",
")",
"# determine alleles to count",
... | Count the number of calls of each allele per variant.
Parameters
----------
max_allele : int, optional
The highest allele index to count. Alleles greater than this
index will be ignored.
subpop : array_like, int, optional
Indices of haplotypes to incl... | [
"Count",
"the",
"number",
"of",
"calls",
"of",
"each",
"allele",
"per",
"variant",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2358-L2404 |
cggh/scikit-allel | allel/model/ndarray.py | HaplotypeArray.map_alleles | def map_alleles(self, mapping, copy=True):
"""Transform alleles via a mapping.
Parameters
----------
mapping : ndarray, int8, shape (n_variants, max_allele)
An array defining the allele mapping for each variant.
copy : bool, optional
If True, return a new... | python | def map_alleles(self, mapping, copy=True):
"""Transform alleles via a mapping.
Parameters
----------
mapping : ndarray, int8, shape (n_variants, max_allele)
An array defining the allele mapping for each variant.
copy : bool, optional
If True, return a new... | [
"def",
"map_alleles",
"(",
"self",
",",
"mapping",
",",
"copy",
"=",
"True",
")",
":",
"# check inputs",
"mapping",
"=",
"asarray_ndim",
"(",
"mapping",
",",
"2",
")",
"check_dim0_aligned",
"(",
"self",
",",
"mapping",
")",
"# use optimisation",
"mapping",
"... | Transform alleles via a mapping.
Parameters
----------
mapping : ndarray, int8, shape (n_variants, max_allele)
An array defining the allele mapping for each variant.
copy : bool, optional
If True, return a new array; if False, apply mapping in place
(... | [
"Transform",
"alleles",
"via",
"a",
"mapping",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2432-L2486 |
cggh/scikit-allel | allel/model/ndarray.py | HaplotypeArray.distinct | def distinct(self):
"""Return sets of indices for each distinct haplotype."""
# setup collection
d = collections.defaultdict(set)
# iterate over haplotypes
for i in range(self.shape[1]):
# hash the haplotype
k = hash(self.values[:, i].tobytes())
... | python | def distinct(self):
"""Return sets of indices for each distinct haplotype."""
# setup collection
d = collections.defaultdict(set)
# iterate over haplotypes
for i in range(self.shape[1]):
# hash the haplotype
k = hash(self.values[:, i].tobytes())
... | [
"def",
"distinct",
"(",
"self",
")",
":",
"# setup collection",
"d",
"=",
"collections",
".",
"defaultdict",
"(",
"set",
")",
"# iterate over haplotypes",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"shape",
"[",
"1",
"]",
")",
":",
"# hash the haplotype",
... | Return sets of indices for each distinct haplotype. | [
"Return",
"sets",
"of",
"indices",
"for",
"each",
"distinct",
"haplotype",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2492-L2508 |
cggh/scikit-allel | allel/model/ndarray.py | HaplotypeArray.distinct_counts | def distinct_counts(self):
"""Return counts for each distinct haplotype."""
# hash the haplotypes
k = [hash(self.values[:, i].tobytes()) for i in range(self.shape[1])]
# count and sort
# noinspection PyArgumentList
counts = sorted(collections.Counter(k).values(), revers... | python | def distinct_counts(self):
"""Return counts for each distinct haplotype."""
# hash the haplotypes
k = [hash(self.values[:, i].tobytes()) for i in range(self.shape[1])]
# count and sort
# noinspection PyArgumentList
counts = sorted(collections.Counter(k).values(), revers... | [
"def",
"distinct_counts",
"(",
"self",
")",
":",
"# hash the haplotypes",
"k",
"=",
"[",
"hash",
"(",
"self",
".",
"values",
"[",
":",
",",
"i",
"]",
".",
"tobytes",
"(",
")",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"shape",
"[",
"1",
"... | Return counts for each distinct haplotype. | [
"Return",
"counts",
"for",
"each",
"distinct",
"haplotype",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2510-L2520 |
cggh/scikit-allel | allel/model/ndarray.py | HaplotypeArray.distinct_frequencies | def distinct_frequencies(self):
"""Return frequencies for each distinct haplotype."""
c = self.distinct_counts()
n = self.shape[1]
return c / n | python | def distinct_frequencies(self):
"""Return frequencies for each distinct haplotype."""
c = self.distinct_counts()
n = self.shape[1]
return c / n | [
"def",
"distinct_frequencies",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"distinct_counts",
"(",
")",
"n",
"=",
"self",
".",
"shape",
"[",
"1",
"]",
"return",
"c",
"/",
"n"
] | Return frequencies for each distinct haplotype. | [
"Return",
"frequencies",
"for",
"each",
"distinct",
"haplotype",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2522-L2527 |
cggh/scikit-allel | allel/model/ndarray.py | AlleleCountsArray.to_frequencies | def to_frequencies(self, fill=np.nan):
"""Compute allele frequencies.
Parameters
----------
fill : float, optional
Value to use when number of allele calls is 0.
Returns
-------
af : ndarray, float, shape (n_variants, n_alleles)
Examples
... | python | def to_frequencies(self, fill=np.nan):
"""Compute allele frequencies.
Parameters
----------
fill : float, optional
Value to use when number of allele calls is 0.
Returns
-------
af : ndarray, float, shape (n_variants, n_alleles)
Examples
... | [
"def",
"to_frequencies",
"(",
"self",
",",
"fill",
"=",
"np",
".",
"nan",
")",
":",
"an",
"=",
"np",
".",
"sum",
"(",
"self",
",",
"axis",
"=",
"1",
")",
"[",
":",
",",
"None",
"]",
"with",
"ignore_invalid",
"(",
")",
":",
"af",
"=",
"np",
".... | Compute allele frequencies.
Parameters
----------
fill : float, optional
Value to use when number of allele calls is 0.
Returns
-------
af : ndarray, float, shape (n_variants, n_alleles)
Examples
--------
>>> import allel
>>... | [
"Compute",
"allele",
"frequencies",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2658-L2689 |
cggh/scikit-allel | allel/model/ndarray.py | AlleleCountsArray.max_allele | def max_allele(self):
"""Return the highest allele index for each variant.
Returns
-------
n : ndarray, int, shape (n_variants,)
Allele index array.
Examples
--------
>>> import allel
>>> g = allel.GenotypeArray([[[0, 0], [0, 1]],
..... | python | def max_allele(self):
"""Return the highest allele index for each variant.
Returns
-------
n : ndarray, int, shape (n_variants,)
Allele index array.
Examples
--------
>>> import allel
>>> g = allel.GenotypeArray([[[0, 0], [0, 1]],
..... | [
"def",
"max_allele",
"(",
"self",
")",
":",
"out",
"=",
"np",
".",
"empty",
"(",
"self",
".",
"shape",
"[",
"0",
"]",
",",
"dtype",
"=",
"'i1'",
")",
"out",
".",
"fill",
"(",
"-",
"1",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"shape"... | Return the highest allele index for each variant.
Returns
-------
n : ndarray, int, shape (n_variants,)
Allele index array.
Examples
--------
>>> import allel
>>> g = allel.GenotypeArray([[[0, 0], [0, 1]],
... [[0, 2... | [
"Return",
"the",
"highest",
"allele",
"index",
"for",
"each",
"variant",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2714-L2740 |
cggh/scikit-allel | allel/model/ndarray.py | AlleleCountsArray.is_non_segregating | def is_non_segregating(self, allele=None):
"""Find non-segregating variants (where at most one allele is
observed).
Parameters
----------
allele : int, optional
Allele index.
Returns
-------
out : ndarray, bool, shape (n_variants,)
... | python | def is_non_segregating(self, allele=None):
"""Find non-segregating variants (where at most one allele is
observed).
Parameters
----------
allele : int, optional
Allele index.
Returns
-------
out : ndarray, bool, shape (n_variants,)
... | [
"def",
"is_non_segregating",
"(",
"self",
",",
"allele",
"=",
"None",
")",
":",
"if",
"allele",
"is",
"None",
":",
"return",
"self",
".",
"allelism",
"(",
")",
"<=",
"1",
"else",
":",
"return",
"(",
"self",
".",
"allelism",
"(",
")",
"==",
"1",
")"... | Find non-segregating variants (where at most one allele is
observed).
Parameters
----------
allele : int, optional
Allele index.
Returns
-------
out : ndarray, bool, shape (n_variants,)
Boolean array where elements are True if variant mat... | [
"Find",
"non",
"-",
"segregating",
"variants",
"(",
"where",
"at",
"most",
"one",
"allele",
"is",
"observed",
")",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2819-L2853 |
cggh/scikit-allel | allel/model/ndarray.py | AlleleCountsArray.is_biallelic_01 | def is_biallelic_01(self, min_mac=None):
"""Find variants biallelic for the reference (0) and first alternate
(1) allele.
Parameters
----------
min_mac : int, optional
Minimum minor allele count.
Returns
-------
out : ndarray, bool, shape (n_... | python | def is_biallelic_01(self, min_mac=None):
"""Find variants biallelic for the reference (0) and first alternate
(1) allele.
Parameters
----------
min_mac : int, optional
Minimum minor allele count.
Returns
-------
out : ndarray, bool, shape (n_... | [
"def",
"is_biallelic_01",
"(",
"self",
",",
"min_mac",
"=",
"None",
")",
":",
"loc",
"=",
"self",
".",
"is_biallelic",
"(",
")",
"&",
"(",
"self",
".",
"max_allele",
"(",
")",
"==",
"1",
")",
"if",
"min_mac",
"is",
"not",
"None",
":",
"# noinspection... | Find variants biallelic for the reference (0) and first alternate
(1) allele.
Parameters
----------
min_mac : int, optional
Minimum minor allele count.
Returns
-------
out : ndarray, bool, shape (n_variants,)
Boolean array where elements ... | [
"Find",
"variants",
"biallelic",
"for",
"the",
"reference",
"(",
"0",
")",
"and",
"first",
"alternate",
"(",
"1",
")",
"allele",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2931-L2951 |
cggh/scikit-allel | allel/model/ndarray.py | AlleleCountsArray.map_alleles | def map_alleles(self, mapping, max_allele=None):
"""Transform alleles via a mapping.
Parameters
----------
mapping : ndarray, int8, shape (n_variants, max_allele)
An array defining the allele mapping for each variant.
max_allele : int, optional
Highest al... | python | def map_alleles(self, mapping, max_allele=None):
"""Transform alleles via a mapping.
Parameters
----------
mapping : ndarray, int8, shape (n_variants, max_allele)
An array defining the allele mapping for each variant.
max_allele : int, optional
Highest al... | [
"def",
"map_alleles",
"(",
"self",
",",
"mapping",
",",
"max_allele",
"=",
"None",
")",
":",
"# ensure correct dimensionality and matching dtype",
"mapping",
"=",
"asarray_ndim",
"(",
"mapping",
",",
"2",
",",
"dtype",
"=",
"self",
".",
"dtype",
")",
"check_dim0... | Transform alleles via a mapping.
Parameters
----------
mapping : ndarray, int8, shape (n_variants, max_allele)
An array defining the allele mapping for each variant.
max_allele : int, optional
Highest allele index expected in the output. If not provided
... | [
"Transform",
"alleles",
"via",
"a",
"mapping",
"."
] | train | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2971-L3027 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.