id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 51 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1,000 | 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):
# 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 ValueError('invalid stop/start')
# copy block... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L16-L34 |
1,001 | 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):
# setup
storage = _util.get_storage(storage)
blen = _util.get_blen_array(data, blen)
if stop is None:
stop = len(data)
else:
stop = min(stop, len(data))
length = stop - start
if le... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L37-L62 |
1,002 | 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):
# setup
names, columns = _util.check_table_like(tbl)
storage = _util.get_storage(storage)
blen = _util.get_blen_table(tbl, blen)
if stop is None:
stop = len(columns[0])
else:
... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L65-L92 |
1,003 | 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):
# 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_array(data, blen)
if isinstance(data, tuple):
... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L95-L130 |
1,004 | 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):
# setup
storage = _util.get_storage(storage)
blen = _util.get_blen_array(data, blen)
length = len(data)
# normalise axis arg
if isinstance(axis, int):
... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L133-L185 |
1,005 | 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):
return reduce_axis(data, axis=axis, reducer=np.amax,
block_reducer=np.maximum, mapper=mapper,
blen=blen, storage=storage, create=create, **kwargs) | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L188-L193 |
1,006 | 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):
return reduce_axis(data, axis=axis, reducer=np.amin,
block_reducer=np.minimum, mapper=mapper,
blen=blen, storage=storage, create=create, **kwargs) | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L196-L201 |
1,007 | 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):
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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L205-L210 |
1,008 | 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):
return reduce_axis(data, reducer=np.count_nonzero,
block_reducer=np.add, mapper=mapper,
blen=blen, storage=storage, create=create, **kwargs) | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L213-L218 |
1,009 | 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):
# TODO refactor sel0 and sel1 normalization with ndarray.subset
# setup
storage = _util.get_storage(storage)
blen = _util.get_blen_array(data, blen)
length = len(data)
if sel0 is not None:
... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L384-L437 |
1,010 | 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):
# normalise scalars
if hasattr(other, 'shape') and len(other.shape) == 0:
other = other[()]
if np.isscalar(other):
def f(block):
return op(block, other)
return map_blocks(dat... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L505-L525 |
1,011 | 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):
# setup
storage = _util.get_storage(storage)
names, columns = _util.check_table_like(tbl)
length = len(columns[0])
if vm_kwargs is None:
vm_kwargs = dict()
# s... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L545-L586 |
1,012 | 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'):
ref = asarray_ndim(ref, 1)
alt = asarray_ndim(alt, 1, 2)
alleles = asarray_ndim(alleles, 1, 2)
check_dim0_aligned(ref, alt, alleles)
# reshape for convenience
ref = ref[:, None]
if alt.ndim == 1:
alt = alt[:, None]
if all... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/util.py#L17-L98 |
1,013 | 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):
# check inputs
ac1 = asarray_ndim(ac1, 2)
ac2 = asarray_ndim(ac2, 2)
check_dim0_aligned(ac1, ac2)
ac1, ac2 = ensure_dim1_aligned(ac1, ac2)
# stack allele counts for convenience
pac = np.dstack([ac1, ac2])
# count numbers of alleles called in each... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/util.py#L101-L157 |
1,014 | 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):
# check inputs
acs = [asarray_ndim(ac, 2) for ac in acs]
check_dim0_aligned(*acs)
acs = ensure_dim1_aligned(*acs)
# stack allele counts for convenience
pac = np.dstack(acs)
# count the numbers of populations with each allele
npa = np.sum(pac > 0, axis=... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/util.py#L160-L213 |
1,015 | 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):
from allel.stats.admixture import patterson_f2, h_hat
num = patterson_f2(aca, acb)
den = num + h_hat(aca) + h_hat(acb)
return num, den | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/fst.py#L330-L360 |
1,016 | 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):
# calculate per-variant values
a, b, c = weir_cockerham_fst(g, subpops, max_allele=max_allele)
# calculate overall estimate
a_sum = np.nansum(a)
b_sum = np.nansum(b)
c_sum = np.nansum(c)
fst = a_sum / (a_sum + b_sum + c_sum)... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/fst.py#L669-L716 |
1,017 | 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):
import matplotlib.pyplot as plt
# check inputs
m_square = ensure_square(m)
# blank out lower triangle and flip up/down
m_square = np.tril(m_square)[::-1, :]
# set up axes
if ax is None:
# make a square figure wit... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/ld.py#L233-L292 |
1,018 | 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):
import h5py
h5f = None
if isinstance(parent, str):
h5f = h5py.File(parent, mode='a')
parent = h5f
try:
kwargs.setdefault('chunks', True) # auto-chunking
kwargs.setdefault('dtype', a.dtype)
kwargs.setdefault('compr... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/io/util.py#L11-L51 |
1,019 | 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):
import h5py
h5f = None
if len(args) == 1:
group = args[0]
elif len(args) == 2:
file_path, node_path = args
h5f = h5py.File(file_path, mode='r')
try:
group = h5f[node_path]
except Exception as e:
... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/io/util.py#L55-L146 |
1,020 | 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):
import h5py
h5f = None
if isinstance(parent, str):
h5f = h5py.File(parent, mode='a')
parent = h5f
try:
h5g = parent.require_group(name)
for n in ra.dtype.names:
array_to_hdf5(ra[n], h5g, n, **kwargs)
... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/io/util.py#L149-L188 |
1,021 | 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):
# 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)
# ensure indices
if sel0 is not None and sel0.dt... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L43-L69 |
1,022 | 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'):
if vm == 'numexpr':
import numexpr as ne
return ne.evaluate(expression, local_dict=self)
else:
if PY2:
# locals must be a mapping
m = {k: self[k] for k in self.dtype.names}
else:
... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L129-L154 |
1,023 | 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'):
condition = self.eval(expression, vm=vm)
return self.compress(condition) | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L156-L173 |
1,024 | 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):
if self.mask is None:
raise ValueError('no mask is set')
# apply the mask
data = np.array(self.values, copy=copy)
data[self.mask, ...] = value
if copy:
out = type(self)(data) # wrap
out.is_phased =... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L332-L380 |
1,025 | 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):
out = np.all(self.values >= 0, axis=-1)
# handle mask
if self.mask is not None:
out &= ~self.mask
return out | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L382-L417 |
1,026 | 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):
out = np.any(self.values < 0, axis=-1)
# handle mask
if self.mask is not None:
out |= self.mask
return out | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L419-L454 |
1,027 | 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):
if allele is None:
allele1 = self.values[..., 0, np.newaxis]
other_alleles = self.values[..., 1:]
tmp = (allele1 >= 0) & (allele1 == other_alleles)
out = np.all(tmp, axis=-1)
else:
out = np.all(self.values == alle... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L456-L506 |
1,028 | 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):
allele1 = self.values[..., 0, np.newaxis] # type: np.ndarray
other_alleles = self.values[..., 1:] # type: np.ndarray
out = np.all(self.values >= 0, axis=-1) & np.any(allele1 != other_alleles, axis=-1)
if allele is not None:
out &= np.any(self.... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L580-L625 |
1,029 | 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):
# guard conditions
if not len(call) == self.shape[-1]:
raise ValueError('invalid call ploidy: %s', repr(call))
if self.ndim == 2:
call = np.asarray(call)[np.newaxis, :]
else:
call = np.asarray(call)[np.newaxis, np.newaxis, :]
... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L627-L674 |
1,030 | 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):
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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L676-L686 |
1,031 | 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):
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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L688-L698 |
1,032 | 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):
b = self.is_hom(allele=allele)
return np.sum(b, axis=axis) | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L700-L712 |
1,033 | 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):
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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L714-L724 |
1,034 | 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):
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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L726-L736 |
1,035 | 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):
b = self.is_het(allele=allele)
return np.sum(b, axis=axis) | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L738-L750 |
1,036 | 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):
b = self.is_call(call=call)
return np.sum(b, axis=axis) | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L752-L764 |
1,037 | 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'):
# count number of alternate alleles
out = np.empty(self.shape[:-1], dtype=dtype)
np.sum(self.values == 0, axis=-1, out=out)
# fill missing calls
if fill != 0:
m = self.is_missing()
out[m] = fill
# handle ma... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L766-L825 |
1,038 | 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'):
# determine alleles to count
if max_allele is None:
max_allele = self.max()
alleles = list(range(max_allele + 1))
# set up output array
outshape = self.shape[:-1] + (len(alleles),)
out = np.zeros(outsha... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L892-L950 |
1,039 | 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):
# how many characters needed per allele call?
if max_allele is None:
max_allele = np.max(self)
if max_allele <= 0:
max_allele = 1
nchar = int(np.floor(np.log10(max_allele))) + 1
# convert to string
a = self.astype... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L952-L1025 |
1,040 | 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):
check_ploidy(self.ploidy, 2)
if boundscheck:
amx = self.max()
if amx > 14:
raise ValueError('max allele for packing is 14, found %s' % amx)
amn = self.min()
if amn < -1:
raise ValueErr... | [
"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"... | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1553-L1602 |
1,041 | 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):
# check arguments
packed = np.asarray(packed)
check_ndim(packed, 2)
check_dtype(packed, 'u1')
packed = memoryview_safe(packed)
data = genotype_array_unpack_diploid(packed)
return cls(data) | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1605-L1642 |
1,042 | 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):
h = HaplotypeArray.from_sparse(m, order=order, out=out)
g = h.to_genotypes(ploidy=ploidy)
return g | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1691-L1733 |
1,043 | 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):
# 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.ploidy, dtype='u1')
# create a random index for each genotype ... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1735-L1797 |
1,044 | 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):
if max_allele is None:
max_allele = self.max()
out = {name: self.count_alleles(max_allele=max_allele, subpop=subpop)
for name, subpop in subpops.items()}
return out | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L1855-L1879 |
1,045 | 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):
return subset_haplotype_array(self, sel0, sel1, cls=type(self), subset=subset) | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2088-L2107 |
1,046 | 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):
return concatenate_haplotype_array(self, others, axis=axis, cls=type(self),
concatenate=np.concatenate) | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2109-L2147 |
1,047 | 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):
# check ploidy is compatible
if (self.shape[1] % ploidy) > 0:
raise ValueError('incompatible ploidy')
# reshape
newshape = (self.shape[0], -1, ploidy)
data = self.reshape(newshape)
# wrap
g = GenotypeArray(... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2202-L2246 |
1,048 | 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):
import scipy.sparse
# check arguments
if not scipy.sparse.isspmatrix(m):
raise ValueError('not a sparse matrix: %r' % m)
# convert to dense array
data = m.toarray(order=order, out=out)
# wrap
h = HaplotypeAr... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2306-L2356 |
1,049 | 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):
# 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())
# collect
d[k].add(i)
# extract sets, so... | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2492-L2508 |
1,050 | 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):
# 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(), reverse=True)
return np.asarray(counts) | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2510-L2520 |
1,051 | 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):
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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2522-L2527 |
1,052 | 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):
an = np.sum(self, axis=1)[:, None]
with ignore_invalid():
af = np.where(an > 0, self / an, fill)
return af | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2658-L2689 |
1,053 | 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):
out = np.empty(self.shape[0], dtype='i1')
out.fill(-1)
for i in range(self.shape[1]):
d = self.values[:, i] > 0
out[d] = i
return out | [
"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",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L2714-L2740 |
1,054 | cggh/scikit-allel | allel/model/ndarray.py | SortedIndex.is_unique | def is_unique(self):
"""True if no duplicate entries."""
if self._is_unique is None:
t = self.values[:-1] == self.values[1:] # type: np.ndarray
self._is_unique = ~np.any(t)
return self._is_unique | python | def is_unique(self):
if self._is_unique is None:
t = self.values[:-1] == self.values[1:] # type: np.ndarray
self._is_unique = ~np.any(t)
return self._is_unique | [
"def",
"is_unique",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_unique",
"is",
"None",
":",
"t",
"=",
"self",
".",
"values",
"[",
":",
"-",
"1",
"]",
"==",
"self",
".",
"values",
"[",
"1",
":",
"]",
"# type: np.ndarray",
"self",
".",
"_is_unique... | True if no duplicate entries. | [
"True",
"if",
"no",
"duplicate",
"entries",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L3404-L3409 |
1,055 | cggh/scikit-allel | allel/model/ndarray.py | SortedIndex.intersect | def intersect(self, other):
"""Intersect with `other` sorted index.
Parameters
----------
other : array_like, int
Array of values to intersect with.
Returns
-------
out : SortedIndex
Values in common.
Examples
--------
... | python | def intersect(self, other):
loc = self.locate_keys(other, strict=False)
return self.compress(loc, axis=0) | [
"def",
"intersect",
"(",
"self",
",",
"other",
")",
":",
"loc",
"=",
"self",
".",
"locate_keys",
"(",
"other",
",",
"strict",
"=",
"False",
")",
"return",
"self",
".",
"compress",
"(",
"loc",
",",
"axis",
"=",
"0",
")"
] | Intersect with `other` sorted index.
Parameters
----------
other : array_like, int
Array of values to intersect with.
Returns
-------
out : SortedIndex
Values in common.
Examples
--------
>>> import allel
>>> idx... | [
"Intersect",
"with",
"other",
"sorted",
"index",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L3558-L3584 |
1,056 | cggh/scikit-allel | allel/model/ndarray.py | SortedIndex.locate_intersection_ranges | def locate_intersection_ranges(self, starts, stops):
"""Locate the intersection with a set of ranges.
Parameters
----------
starts : array_like, int
Range start values.
stops : array_like, int
Range stop values.
Returns
-------
lo... | python | def locate_intersection_ranges(self, starts, stops):
# check inputs
starts = asarray_ndim(starts, 1)
stops = asarray_ndim(stops, 1)
check_dim0_aligned(starts, stops)
# find indices of start and stop values in idx
start_indices = np.searchsorted(self, starts)
stop... | [
"def",
"locate_intersection_ranges",
"(",
"self",
",",
"starts",
",",
"stops",
")",
":",
"# check inputs",
"starts",
"=",
"asarray_ndim",
"(",
"starts",
",",
"1",
")",
"stops",
"=",
"asarray_ndim",
"(",
"stops",
",",
"1",
")",
"check_dim0_aligned",
"(",
"sta... | Locate the intersection with a set of ranges.
Parameters
----------
starts : array_like, int
Range start values.
stops : array_like, int
Range stop values.
Returns
-------
loc : ndarray, bool
Boolean array with location of ent... | [
"Locate",
"the",
"intersection",
"with",
"a",
"set",
"of",
"ranges",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L3665-L3724 |
1,057 | cggh/scikit-allel | allel/model/ndarray.py | SortedIndex.locate_ranges | def locate_ranges(self, starts, stops, strict=True):
"""Locate items within the given ranges.
Parameters
----------
starts : array_like, int
Range start values.
stops : array_like, int
Range stop values.
strict : bool, optional
If True... | python | def locate_ranges(self, starts, stops, strict=True):
loc, found = self.locate_intersection_ranges(starts, stops)
if strict and np.any(~found):
raise KeyError(starts[~found], stops[~found])
return loc | [
"def",
"locate_ranges",
"(",
"self",
",",
"starts",
",",
"stops",
",",
"strict",
"=",
"True",
")",
":",
"loc",
",",
"found",
"=",
"self",
".",
"locate_intersection_ranges",
"(",
"starts",
",",
"stops",
")",
"if",
"strict",
"and",
"np",
".",
"any",
"(",... | Locate items within the given ranges.
Parameters
----------
starts : array_like, int
Range start values.
stops : array_like, int
Range stop values.
strict : bool, optional
If True, raise KeyError if any ranges contain no entries.
Retu... | [
"Locate",
"items",
"within",
"the",
"given",
"ranges",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L3726-L3767 |
1,058 | cggh/scikit-allel | allel/model/ndarray.py | SortedIndex.intersect_ranges | def intersect_ranges(self, starts, stops):
"""Intersect with a set of ranges.
Parameters
----------
starts : array_like, int
Range start values.
stops : array_like, int
Range stop values.
Returns
-------
idx : SortedIndex
... | python | def intersect_ranges(self, starts, stops):
loc = self.locate_ranges(starts, stops, strict=False)
return self.compress(loc, axis=0) | [
"def",
"intersect_ranges",
"(",
"self",
",",
"starts",
",",
"stops",
")",
":",
"loc",
"=",
"self",
".",
"locate_ranges",
"(",
"starts",
",",
"stops",
",",
"strict",
"=",
"False",
")",
"return",
"self",
".",
"compress",
"(",
"loc",
",",
"axis",
"=",
"... | Intersect with a set of ranges.
Parameters
----------
starts : array_like, int
Range start values.
stops : array_like, int
Range stop values.
Returns
-------
idx : SortedIndex
Examples
--------
>>> import allel
... | [
"Intersect",
"with",
"a",
"set",
"of",
"ranges",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L3769-L3800 |
1,059 | cggh/scikit-allel | allel/model/ndarray.py | VariantTable.set_index | def set_index(self, index):
"""Set or reset the index.
Parameters
----------
index : string or pair of strings, optional
Names of columns to use for positional index, e.g., 'POS' if table
contains a 'POS' column and records from a single
chromosome/co... | python | def set_index(self, index):
if index is None:
pass
elif isinstance(index, str):
index = SortedIndex(self[index], copy=False)
elif isinstance(index, (tuple, list)) and len(index) == 2:
index = SortedMultiIndex(self[index[0]], self[index[1]],
... | [
"def",
"set_index",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
"is",
"None",
":",
"pass",
"elif",
"isinstance",
"(",
"index",
",",
"str",
")",
":",
"index",
"=",
"SortedIndex",
"(",
"self",
"[",
"index",
"]",
",",
"copy",
"=",
"False",
")"... | Set or reset the index.
Parameters
----------
index : string or pair of strings, optional
Names of columns to use for positional index, e.g., 'POS' if table
contains a 'POS' column and records from a single
chromosome/contig, or ('CHROM', 'POS') if table cont... | [
"Set",
"or",
"reset",
"the",
"index",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L4541-L4563 |
1,060 | cggh/scikit-allel | allel/model/ndarray.py | VariantTable.query_position | def query_position(self, chrom=None, position=None):
"""Query the table, returning row or rows matching the given genomic
position.
Parameters
----------
chrom : string, optional
Chromosome/contig.
position : int, optional
Position (1-based).
... | python | def query_position(self, chrom=None, position=None):
if self.index is None:
raise ValueError('no index has been set')
if isinstance(self.index, SortedIndex):
# ignore chrom
loc = self.index.locate_key(position)
else:
loc = self.index.locate_key(chr... | [
"def",
"query_position",
"(",
"self",
",",
"chrom",
"=",
"None",
",",
"position",
"=",
"None",
")",
":",
"if",
"self",
".",
"index",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'no index has been set'",
")",
"if",
"isinstance",
"(",
"self",
".",
"ind... | Query the table, returning row or rows matching the given genomic
position.
Parameters
----------
chrom : string, optional
Chromosome/contig.
position : int, optional
Position (1-based).
Returns
-------
result : row or VariantTabl... | [
"Query",
"the",
"table",
"returning",
"row",
"or",
"rows",
"matching",
"the",
"given",
"genomic",
"position",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L4565-L4589 |
1,061 | cggh/scikit-allel | allel/model/ndarray.py | VariantTable.query_region | def query_region(self, chrom=None, start=None, stop=None):
"""Query the table, returning row or rows within the given genomic
region.
Parameters
----------
chrom : string, optional
Chromosome/contig.
start : int, optional
Region start position (1-... | python | def query_region(self, chrom=None, start=None, stop=None):
if self.index is None:
raise ValueError('no index has been set')
if isinstance(self.index, SortedIndex):
# ignore chrom
loc = self.index.locate_range(start, stop)
else:
loc = self.index.loc... | [
"def",
"query_region",
"(",
"self",
",",
"chrom",
"=",
"None",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"if",
"self",
".",
"index",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'no index has been set'",
")",
"if",
"isinstance",
... | Query the table, returning row or rows within the given genomic
region.
Parameters
----------
chrom : string, optional
Chromosome/contig.
start : int, optional
Region start position (1-based).
stop : int, optional
Region stop position ... | [
"Query",
"the",
"table",
"returning",
"row",
"or",
"rows",
"within",
"the",
"given",
"genomic",
"region",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L4591-L4616 |
1,062 | cggh/scikit-allel | allel/model/ndarray.py | FeatureTable.to_mask | def to_mask(self, size, start_name='start', stop_name='end'):
"""Construct a mask array where elements are True if the fall within
features in the table.
Parameters
----------
size : int
Size of chromosome/contig.
start_name : string, optional
Na... | python | def to_mask(self, size, start_name='start', stop_name='end'):
m = np.zeros(size, dtype=bool)
for start, stop in self[[start_name, stop_name]]:
m[start-1:stop] = True
return m | [
"def",
"to_mask",
"(",
"self",
",",
"size",
",",
"start_name",
"=",
"'start'",
",",
"stop_name",
"=",
"'end'",
")",
":",
"m",
"=",
"np",
".",
"zeros",
"(",
"size",
",",
"dtype",
"=",
"bool",
")",
"for",
"start",
",",
"stop",
"in",
"self",
"[",
"[... | Construct a mask array where elements are True if the fall within
features in the table.
Parameters
----------
size : int
Size of chromosome/contig.
start_name : string, optional
Name of column with start coordinates.
stop_name : string, optional... | [
"Construct",
"a",
"mask",
"array",
"where",
"elements",
"are",
"True",
"if",
"the",
"fall",
"within",
"features",
"in",
"the",
"table",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L4734-L4757 |
1,063 | cggh/scikit-allel | allel/model/ndarray.py | FeatureTable.from_gff3 | def from_gff3(path, attributes=None, region=None, score_fill=-1, phase_fill=-1,
attributes_fill='.', dtype=None):
"""Read a feature table from a GFF3 format file.
Parameters
----------
path : string
File path.
attributes : list of strings, optional
... | python | def from_gff3(path, attributes=None, region=None, score_fill=-1, phase_fill=-1,
attributes_fill='.', dtype=None):
a = gff3_to_recarray(path, attributes=attributes, region=region,
score_fill=score_fill, phase_fill=phase_fill,
attributes_... | [
"def",
"from_gff3",
"(",
"path",
",",
"attributes",
"=",
"None",
",",
"region",
"=",
"None",
",",
"score_fill",
"=",
"-",
"1",
",",
"phase_fill",
"=",
"-",
"1",
",",
"attributes_fill",
"=",
"'.'",
",",
"dtype",
"=",
"None",
")",
":",
"a",
"=",
"gff... | Read a feature table from a GFF3 format file.
Parameters
----------
path : string
File path.
attributes : list of strings, optional
List of columns to extract from the "attributes" field.
region : string, optional
Genome region to extract. If ... | [
"Read",
"a",
"feature",
"table",
"from",
"a",
"GFF3",
"format",
"file",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L4760-L4795 |
1,064 | cggh/scikit-allel | allel/stats/distance.py | pcoa | def pcoa(dist):
"""Perform principal coordinate analysis of a distance matrix, a.k.a.
classical multi-dimensional scaling.
Parameters
----------
dist : array_like
Distance matrix in condensed form.
Returns
-------
coords : ndarray, shape (n_samples, n_dimensions)
Transf... | python | def pcoa(dist):
import scipy.linalg
# This implementation is based on the skbio.math.stats.ordination.PCoA
# implementation, with some minor adjustments.
# check inputs
dist = ensure_square(dist)
# perform scaling
e_matrix = (dist ** 2) / -2
row_means = np.mean(e_matrix, axis=1, keepd... | [
"def",
"pcoa",
"(",
"dist",
")",
":",
"import",
"scipy",
".",
"linalg",
"# This implementation is based on the skbio.math.stats.ordination.PCoA",
"# implementation, with some minor adjustments.",
"# check inputs",
"dist",
"=",
"ensure_square",
"(",
"dist",
")",
"# perform scali... | Perform principal coordinate analysis of a distance matrix, a.k.a.
classical multi-dimensional scaling.
Parameters
----------
dist : array_like
Distance matrix in condensed form.
Returns
-------
coords : ndarray, shape (n_samples, n_dimensions)
Transformed coordinates for t... | [
"Perform",
"principal",
"coordinate",
"analysis",
"of",
"a",
"distance",
"matrix",
"a",
".",
"k",
".",
"a",
".",
"classical",
"multi",
"-",
"dimensional",
"scaling",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/distance.py#L199-L252 |
1,065 | cggh/scikit-allel | allel/stats/distance.py | condensed_coords | def condensed_coords(i, j, n):
"""Transform square distance matrix coordinates to the corresponding
index into a condensed, 1D form of the matrix.
Parameters
----------
i : int
Row index.
j : int
Column index.
n : int
Size of the square matrix (length of first or sec... | python | def condensed_coords(i, j, n):
# guard conditions
if i == j or i >= n or j >= n or i < 0 or j < 0:
raise ValueError('invalid coordinates: %s, %s' % (i, j))
# normalise order
i, j = sorted([i, j])
# calculate number of items in rows before this one (sum of arithmetic
# progression)
... | [
"def",
"condensed_coords",
"(",
"i",
",",
"j",
",",
"n",
")",
":",
"# guard conditions",
"if",
"i",
"==",
"j",
"or",
"i",
">=",
"n",
"or",
"j",
">=",
"n",
"or",
"i",
"<",
"0",
"or",
"j",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'invalid coordi... | Transform square distance matrix coordinates to the corresponding
index into a condensed, 1D form of the matrix.
Parameters
----------
i : int
Row index.
j : int
Column index.
n : int
Size of the square matrix (length of first or second dimension).
Returns
-----... | [
"Transform",
"square",
"distance",
"matrix",
"coordinates",
"to",
"the",
"corresponding",
"index",
"into",
"a",
"condensed",
"1D",
"form",
"of",
"the",
"matrix",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/distance.py#L255-L288 |
1,066 | cggh/scikit-allel | allel/stats/distance.py | condensed_coords_within | def condensed_coords_within(pop, n):
"""Return indices into a condensed distance matrix for all
pairwise comparisons within the given population.
Parameters
----------
pop : array_like, int
Indices of samples or haplotypes within the population.
n : int
Size of the square matrix... | python | def condensed_coords_within(pop, n):
return [condensed_coords(i, j, n)
for i, j in itertools.combinations(sorted(pop), 2)] | [
"def",
"condensed_coords_within",
"(",
"pop",
",",
"n",
")",
":",
"return",
"[",
"condensed_coords",
"(",
"i",
",",
"j",
",",
"n",
")",
"for",
"i",
",",
"j",
"in",
"itertools",
".",
"combinations",
"(",
"sorted",
"(",
"pop",
")",
",",
"2",
")",
"]"... | Return indices into a condensed distance matrix for all
pairwise comparisons within the given population.
Parameters
----------
pop : array_like, int
Indices of samples or haplotypes within the population.
n : int
Size of the square matrix (length of first or second dimension).
... | [
"Return",
"indices",
"into",
"a",
"condensed",
"distance",
"matrix",
"for",
"all",
"pairwise",
"comparisons",
"within",
"the",
"given",
"population",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/distance.py#L291-L309 |
1,067 | cggh/scikit-allel | allel/stats/distance.py | condensed_coords_between | def condensed_coords_between(pop1, pop2, n):
"""Return indices into a condensed distance matrix for all pairwise
comparisons between two populations.
Parameters
----------
pop1 : array_like, int
Indices of samples or haplotypes within the first population.
pop2 : array_like, int
... | python | def condensed_coords_between(pop1, pop2, n):
return [condensed_coords(i, j, n)
for i, j in itertools.product(sorted(pop1), sorted(pop2))] | [
"def",
"condensed_coords_between",
"(",
"pop1",
",",
"pop2",
",",
"n",
")",
":",
"return",
"[",
"condensed_coords",
"(",
"i",
",",
"j",
",",
"n",
")",
"for",
"i",
",",
"j",
"in",
"itertools",
".",
"product",
"(",
"sorted",
"(",
"pop1",
")",
",",
"s... | Return indices into a condensed distance matrix for all pairwise
comparisons between two populations.
Parameters
----------
pop1 : array_like, int
Indices of samples or haplotypes within the first population.
pop2 : array_like, int
Indices of samples or haplotypes within the second ... | [
"Return",
"indices",
"into",
"a",
"condensed",
"distance",
"matrix",
"for",
"all",
"pairwise",
"comparisons",
"between",
"two",
"populations",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/distance.py#L312-L332 |
1,068 | cggh/scikit-allel | allel/stats/distance.py | plot_pairwise_distance | def plot_pairwise_distance(dist, labels=None, colorbar=True, ax=None,
imshow_kwargs=None):
"""Plot a pairwise distance matrix.
Parameters
----------
dist : array_like
The distance matrix in condensed form.
labels : sequence of strings, optional
Sample labe... | python | def plot_pairwise_distance(dist, labels=None, colorbar=True, ax=None,
imshow_kwargs=None):
import matplotlib.pyplot as plt
# check inputs
dist_square = ensure_square(dist)
# set up axes
if ax is None:
# make a square figure
x = plt.rcParams['figure.figsiz... | [
"def",
"plot_pairwise_distance",
"(",
"dist",
",",
"labels",
"=",
"None",
",",
"colorbar",
"=",
"True",
",",
"ax",
"=",
"None",
",",
"imshow_kwargs",
"=",
"None",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"# check inputs",
"dist_square",
... | Plot a pairwise distance matrix.
Parameters
----------
dist : array_like
The distance matrix in condensed form.
labels : sequence of strings, optional
Sample labels for the axes.
colorbar : bool, optional
If True, add a colorbar to the current figure.
ax : axes, optional... | [
"Plot",
"a",
"pairwise",
"distance",
"matrix",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/distance.py#L335-L396 |
1,069 | cggh/scikit-allel | allel/stats/misc.py | jackknife | def jackknife(values, statistic):
"""Estimate standard error for `statistic` computed over `values` using
the jackknife.
Parameters
----------
values : array_like or tuple of array_like
Input array, or tuple of input arrays.
statistic : function
The statistic to compute.
Re... | python | def jackknife(values, statistic):
if isinstance(values, tuple):
# multiple input arrays
n = len(values[0])
masked_values = [np.ma.asarray(v) for v in values]
for m in masked_values:
assert m.ndim == 1, 'only 1D arrays supported'
assert m.shape[0] == n, 'input ... | [
"def",
"jackknife",
"(",
"values",
",",
"statistic",
")",
":",
"if",
"isinstance",
"(",
"values",
",",
"tuple",
")",
":",
"# multiple input arrays",
"n",
"=",
"len",
"(",
"values",
"[",
"0",
"]",
")",
"masked_values",
"=",
"[",
"np",
".",
"ma",
".",
... | Estimate standard error for `statistic` computed over `values` using
the jackknife.
Parameters
----------
values : array_like or tuple of array_like
Input array, or tuple of input arrays.
statistic : function
The statistic to compute.
Returns
-------
m : float
M... | [
"Estimate",
"standard",
"error",
"for",
"statistic",
"computed",
"over",
"values",
"using",
"the",
"jackknife",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/misc.py#L15-L82 |
1,070 | cggh/scikit-allel | allel/stats/misc.py | tabulate_state_transitions | def tabulate_state_transitions(x, states, pos=None):
"""Construct a dataframe where each row provides information about a state transition.
Parameters
----------
x : array_like, int
1-dimensional array of state values.
states : set
Set of states of interest. Any state value not in t... | python | def tabulate_state_transitions(x, states, pos=None):
# check inputs
x = asarray_ndim(x, 1)
check_integer_dtype(x)
x = memoryview_safe(x)
# find state transitions
switch_points, transitions, _ = state_transitions(x, states)
# start to build a dataframe
items = [('lstate', transitions[:,... | [
"def",
"tabulate_state_transitions",
"(",
"x",
",",
"states",
",",
"pos",
"=",
"None",
")",
":",
"# check inputs",
"x",
"=",
"asarray_ndim",
"(",
"x",
",",
"1",
")",
"check_integer_dtype",
"(",
"x",
")",
"x",
"=",
"memoryview_safe",
"(",
"x",
")",
"# fin... | Construct a dataframe where each row provides information about a state transition.
Parameters
----------
x : array_like, int
1-dimensional array of state values.
states : set
Set of states of interest. Any state value not in this set will be ignored.
pos : array_like, int, optional... | [
"Construct",
"a",
"dataframe",
"where",
"each",
"row",
"provides",
"information",
"about",
"a",
"state",
"transition",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/misc.py#L174-L248 |
1,071 | cggh/scikit-allel | allel/stats/misc.py | tabulate_state_blocks | def tabulate_state_blocks(x, states, pos=None):
"""Construct a dataframe where each row provides information about continuous state blocks.
Parameters
----------
x : array_like, int
1-dimensional array of state values.
states : set
Set of states of interest. Any state value not in t... | python | def tabulate_state_blocks(x, states, pos=None):
# check inputs
x = asarray_ndim(x, 1)
check_integer_dtype(x)
x = memoryview_safe(x)
# find state transitions
switch_points, transitions, observations = state_transitions(x, states)
# setup some helpers
t = transitions[1:, 0]
o = obser... | [
"def",
"tabulate_state_blocks",
"(",
"x",
",",
"states",
",",
"pos",
"=",
"None",
")",
":",
"# check inputs",
"x",
"=",
"asarray_ndim",
"(",
"x",
",",
"1",
")",
"check_integer_dtype",
"(",
"x",
")",
"x",
"=",
"memoryview_safe",
"(",
"x",
")",
"# find sta... | Construct a dataframe where each row provides information about continuous state blocks.
Parameters
----------
x : array_like, int
1-dimensional array of state values.
states : set
Set of states of interest. Any state value not in this set will be ignored.
pos : array_like, int, opt... | [
"Construct",
"a",
"dataframe",
"where",
"each",
"row",
"provides",
"information",
"about",
"continuous",
"state",
"blocks",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/misc.py#L251-L349 |
1,072 | cggh/scikit-allel | allel/io/vcf_write.py | write_vcf | def write_vcf(path, callset, rename=None, number=None, description=None,
fill=None, write_header=True):
"""Preliminary support for writing a VCF file. Currently does not support sample data.
Needs further work."""
names, callset = normalize_callset(callset)
with open(path, 'w') as vcf_fi... | python | def write_vcf(path, callset, rename=None, number=None, description=None,
fill=None, write_header=True):
names, callset = normalize_callset(callset)
with open(path, 'w') as vcf_file:
if write_header:
write_vcf_header(vcf_file, names, callset=callset, rename=rename,
... | [
"def",
"write_vcf",
"(",
"path",
",",
"callset",
",",
"rename",
"=",
"None",
",",
"number",
"=",
"None",
",",
"description",
"=",
"None",
",",
"fill",
"=",
"None",
",",
"write_header",
"=",
"True",
")",
":",
"names",
",",
"callset",
"=",
"normalize_cal... | Preliminary support for writing a VCF file. Currently does not support sample data.
Needs further work. | [
"Preliminary",
"support",
"for",
"writing",
"a",
"VCF",
"file",
".",
"Currently",
"does",
"not",
"support",
"sample",
"data",
".",
"Needs",
"further",
"work",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/io/vcf_write.py#L50-L61 |
1,073 | cggh/scikit-allel | allel/util.py | asarray_ndim | def asarray_ndim(a, *ndims, **kwargs):
"""Ensure numpy array.
Parameters
----------
a : array_like
*ndims : int, optional
Allowed values for number of dimensions.
**kwargs
Passed through to :func:`numpy.array`.
Returns
-------
a : numpy.ndarray
"""
allow_no... | python | def asarray_ndim(a, *ndims, **kwargs):
allow_none = kwargs.pop('allow_none', False)
kwargs.setdefault('copy', False)
if a is None and allow_none:
return None
a = np.array(a, **kwargs)
if a.ndim not in ndims:
if len(ndims) > 1:
expect_str = 'one of %s' % str(ndims)
... | [
"def",
"asarray_ndim",
"(",
"a",
",",
"*",
"ndims",
",",
"*",
"*",
"kwargs",
")",
":",
"allow_none",
"=",
"kwargs",
".",
"pop",
"(",
"'allow_none'",
",",
"False",
")",
"kwargs",
".",
"setdefault",
"(",
"'copy'",
",",
"False",
")",
"if",
"a",
"is",
... | Ensure numpy array.
Parameters
----------
a : array_like
*ndims : int, optional
Allowed values for number of dimensions.
**kwargs
Passed through to :func:`numpy.array`.
Returns
-------
a : numpy.ndarray | [
"Ensure",
"numpy",
"array",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/util.py#L32-L61 |
1,074 | cggh/scikit-allel | allel/util.py | hdf5_cache | def hdf5_cache(filepath=None, parent=None, group=None, names=None, typed=False,
hashed_key=False, **h5dcreate_kwargs):
"""HDF5 cache decorator.
Parameters
----------
filepath : string, optional
Path to HDF5 file. If None a temporary file name will be used.
parent : string, op... | python | def hdf5_cache(filepath=None, parent=None, group=None, names=None, typed=False,
hashed_key=False, **h5dcreate_kwargs):
# initialise HDF5 file path
if filepath is None:
import tempfile
filepath = tempfile.mktemp(prefix='scikit_allel_', suffix='.h5')
atexit.register(os.remov... | [
"def",
"hdf5_cache",
"(",
"filepath",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"group",
"=",
"None",
",",
"names",
"=",
"None",
",",
"typed",
"=",
"False",
",",
"hashed_key",
"=",
"False",
",",
"*",
"*",
"h5dcreate_kwargs",
")",
":",
"# initialise... | HDF5 cache decorator.
Parameters
----------
filepath : string, optional
Path to HDF5 file. If None a temporary file name will be used.
parent : string, optional
Path to group within HDF5 file to use as parent. If None the root
group will be used.
group : string, optional
... | [
"HDF5",
"cache",
"decorator",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/util.py#L283-L401 |
1,075 | cggh/scikit-allel | allel/stats/decomposition.py | pca | def pca(gn, n_components=10, copy=True, scaler='patterson', ploidy=2):
"""Perform principal components analysis of genotype data, via singular
value decomposition.
Parameters
----------
gn : array_like, float, shape (n_variants, n_samples)
Genotypes at biallelic variants, coded as the numb... | python | def pca(gn, n_components=10, copy=True, scaler='patterson', ploidy=2):
# set up the model
model = GenotypePCA(n_components, copy=copy, scaler=scaler, ploidy=ploidy)
# fit the model and project the input data onto the new dimensions
coords = model.fit_transform(gn)
return coords, model | [
"def",
"pca",
"(",
"gn",
",",
"n_components",
"=",
"10",
",",
"copy",
"=",
"True",
",",
"scaler",
"=",
"'patterson'",
",",
"ploidy",
"=",
"2",
")",
":",
"# set up the model",
"model",
"=",
"GenotypePCA",
"(",
"n_components",
",",
"copy",
"=",
"copy",
"... | Perform principal components analysis of genotype data, via singular
value decomposition.
Parameters
----------
gn : array_like, float, shape (n_variants, n_samples)
Genotypes at biallelic variants, coded as the number of alternate
alleles per call (i.e., 0 = hom ref, 1 = het, 2 = hom ... | [
"Perform",
"principal",
"components",
"analysis",
"of",
"genotype",
"data",
"via",
"singular",
"value",
"decomposition",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/decomposition.py#L11-L60 |
1,076 | cggh/scikit-allel | allel/stats/decomposition.py | randomized_pca | def randomized_pca(gn, n_components=10, copy=True, iterated_power=3,
random_state=None, scaler='patterson', ploidy=2):
"""Perform principal components analysis of genotype data, via an
approximate truncated singular value decomposition using randomization
to speed up the computation.
... | python | def randomized_pca(gn, n_components=10, copy=True, iterated_power=3,
random_state=None, scaler='patterson', ploidy=2):
# set up the model
model = GenotypeRandomizedPCA(n_components, copy=copy,
iterated_power=iterated_power,
r... | [
"def",
"randomized_pca",
"(",
"gn",
",",
"n_components",
"=",
"10",
",",
"copy",
"=",
"True",
",",
"iterated_power",
"=",
"3",
",",
"random_state",
"=",
"None",
",",
"scaler",
"=",
"'patterson'",
",",
"ploidy",
"=",
"2",
")",
":",
"# set up the model",
"... | Perform principal components analysis of genotype data, via an
approximate truncated singular value decomposition using randomization
to speed up the computation.
Parameters
----------
gn : array_like, float, shape (n_variants, n_samples)
Genotypes at biallelic variants, coded as the numbe... | [
"Perform",
"principal",
"components",
"analysis",
"of",
"genotype",
"data",
"via",
"an",
"approximate",
"truncated",
"singular",
"value",
"decomposition",
"using",
"randomization",
"to",
"speed",
"up",
"the",
"computation",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/decomposition.py#L126-L187 |
1,077 | cggh/scikit-allel | allel/model/dask.py | get_chunks | def get_chunks(data, chunks=None):
"""Try to guess a reasonable chunk shape to use for block-wise
algorithms operating over `data`."""
if chunks is None:
if hasattr(data, 'chunklen') and hasattr(data, 'shape'):
# bcolz carray, chunk first dimension only
return (data.chunkle... | python | def get_chunks(data, chunks=None):
if chunks is None:
if hasattr(data, 'chunklen') and hasattr(data, 'shape'):
# bcolz carray, chunk first dimension only
return (data.chunklen,) + data.shape[1:]
elif hasattr(data, 'chunks') and hasattr(data, 'shape') and \
l... | [
"def",
"get_chunks",
"(",
"data",
",",
"chunks",
"=",
"None",
")",
":",
"if",
"chunks",
"is",
"None",
":",
"if",
"hasattr",
"(",
"data",
",",
"'chunklen'",
")",
"and",
"hasattr",
"(",
"data",
",",
"'shape'",
")",
":",
"# bcolz carray, chunk first dimension... | Try to guess a reasonable chunk shape to use for block-wise
algorithms operating over `data`. | [
"Try",
"to",
"guess",
"a",
"reasonable",
"chunk",
"shape",
"to",
"use",
"for",
"block",
"-",
"wise",
"algorithms",
"operating",
"over",
"data",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/dask.py#L47-L74 |
1,078 | cggh/scikit-allel | allel/io/gff.py | iter_gff3 | def iter_gff3(path, attributes=None, region=None, score_fill=-1,
phase_fill=-1, attributes_fill='.', tabix='tabix'):
"""Iterate over records in a GFF3 file.
Parameters
----------
path : string
Path to input file.
attributes : list of strings, optional
List of columns t... | python | def iter_gff3(path, attributes=None, region=None, score_fill=-1,
phase_fill=-1, attributes_fill='.', tabix='tabix'):
# prepare fill values for attributes
if attributes is not None:
attributes = list(attributes)
if isinstance(attributes_fill, (list, tuple)):
if len(attri... | [
"def",
"iter_gff3",
"(",
"path",
",",
"attributes",
"=",
"None",
",",
"region",
"=",
"None",
",",
"score_fill",
"=",
"-",
"1",
",",
"phase_fill",
"=",
"-",
"1",
",",
"attributes_fill",
"=",
"'.'",
",",
"tabix",
"=",
"'tabix'",
")",
":",
"# prepare fill... | Iterate over records in a GFF3 file.
Parameters
----------
path : string
Path to input file.
attributes : list of strings, optional
List of columns to extract from the "attributes" field.
region : string, optional
Genome region to extract. If given, file must be position
... | [
"Iterate",
"over",
"records",
"in",
"a",
"GFF3",
"file",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/io/gff.py#L31-L118 |
1,079 | cggh/scikit-allel | allel/io/gff.py | gff3_to_recarray | def gff3_to_recarray(path, attributes=None, region=None, score_fill=-1,
phase_fill=-1, attributes_fill='.', tabix='tabix', dtype=None):
"""Load data from a GFF3 into a NumPy recarray.
Parameters
----------
path : string
Path to input file.
attributes : list of strings, ... | python | def gff3_to_recarray(path, attributes=None, region=None, score_fill=-1,
phase_fill=-1, attributes_fill='.', tabix='tabix', dtype=None):
# read records
recs = list(iter_gff3(path, attributes=attributes, region=region,
score_fill=score_fill, phase_fill=phase_fill,
... | [
"def",
"gff3_to_recarray",
"(",
"path",
",",
"attributes",
"=",
"None",
",",
"region",
"=",
"None",
",",
"score_fill",
"=",
"-",
"1",
",",
"phase_fill",
"=",
"-",
"1",
",",
"attributes_fill",
"=",
"'.'",
",",
"tabix",
"=",
"'tabix'",
",",
"dtype",
"=",... | Load data from a GFF3 into a NumPy recarray.
Parameters
----------
path : string
Path to input file.
attributes : list of strings, optional
List of columns to extract from the "attributes" field.
region : string, optional
Genome region to extract. If given, file must be posi... | [
"Load",
"data",
"from",
"a",
"GFF3",
"into",
"a",
"NumPy",
"recarray",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/io/gff.py#L124-L178 |
1,080 | cggh/scikit-allel | allel/io/gff.py | gff3_to_dataframe | def gff3_to_dataframe(path, attributes=None, region=None, score_fill=-1,
phase_fill=-1, attributes_fill='.', tabix='tabix', **kwargs):
"""Load data from a GFF3 into a pandas DataFrame.
Parameters
----------
path : string
Path to input file.
attributes : list of strings... | python | def gff3_to_dataframe(path, attributes=None, region=None, score_fill=-1,
phase_fill=-1, attributes_fill='.', tabix='tabix', **kwargs):
import pandas
# read records
recs = list(iter_gff3(path, attributes=attributes, region=region,
score_fill=score_fill, phase_... | [
"def",
"gff3_to_dataframe",
"(",
"path",
",",
"attributes",
"=",
"None",
",",
"region",
"=",
"None",
",",
"score_fill",
"=",
"-",
"1",
",",
"phase_fill",
"=",
"-",
"1",
",",
"attributes_fill",
"=",
"'.'",
",",
"tabix",
"=",
"'tabix'",
",",
"*",
"*",
... | Load data from a GFF3 into a pandas DataFrame.
Parameters
----------
path : string
Path to input file.
attributes : list of strings, optional
List of columns to extract from the "attributes" field.
region : string, optional
Genome region to extract. If given, file must be po... | [
"Load",
"data",
"from",
"a",
"GFF3",
"into",
"a",
"pandas",
"DataFrame",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/io/gff.py#L181-L223 |
1,081 | cggh/scikit-allel | allel/stats/selection.py | voight_painting | def voight_painting(h):
"""Paint haplotypes, assigning a unique integer to each shared haplotype
prefix.
Parameters
----------
h : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array.
Returns
-------
painting : ndarray, int, shape (n_variants, n_haplotypes)
... | python | def voight_painting(h):
# check inputs
# N.B., ensure int8 so we can use cython optimisation
h = HaplotypeArray(np.asarray(h), copy=False)
if h.max() > 1:
raise NotImplementedError('only biallelic variants are supported')
if h.min() < 0:
raise NotImplementedError('missing calls are n... | [
"def",
"voight_painting",
"(",
"h",
")",
":",
"# check inputs",
"# N.B., ensure int8 so we can use cython optimisation",
"h",
"=",
"HaplotypeArray",
"(",
"np",
".",
"asarray",
"(",
"h",
")",
",",
"copy",
"=",
"False",
")",
"if",
"h",
".",
"max",
"(",
")",
">... | Paint haplotypes, assigning a unique integer to each shared haplotype
prefix.
Parameters
----------
h : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array.
Returns
-------
painting : ndarray, int, shape (n_variants, n_haplotypes)
Painting array.
indices :... | [
"Paint",
"haplotypes",
"assigning",
"a",
"unique",
"integer",
"to",
"each",
"shared",
"haplotype",
"prefix",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L62-L95 |
1,082 | cggh/scikit-allel | allel/stats/selection.py | plot_voight_painting | def plot_voight_painting(painting, palette='colorblind', flank='right',
ax=None, height_factor=0.01):
"""Plot a painting of shared haplotype prefixes.
Parameters
----------
painting : array_like, int, shape (n_variants, n_haplotypes)
Painting array.
ax : axes, optio... | python | def plot_voight_painting(painting, palette='colorblind', flank='right',
ax=None, height_factor=0.01):
import seaborn as sns
from matplotlib.colors import ListedColormap
import matplotlib.pyplot as plt
if flank == 'left':
painting = painting[::-1]
n_colors = paintin... | [
"def",
"plot_voight_painting",
"(",
"painting",
",",
"palette",
"=",
"'colorblind'",
",",
"flank",
"=",
"'right'",
",",
"ax",
"=",
"None",
",",
"height_factor",
"=",
"0.01",
")",
":",
"import",
"seaborn",
"as",
"sns",
"from",
"matplotlib",
".",
"colors",
"... | Plot a painting of shared haplotype prefixes.
Parameters
----------
painting : array_like, int, shape (n_variants, n_haplotypes)
Painting array.
ax : axes, optional
The axes on which to draw. If not provided, a new figure will be
created.
palette : string, optional
A... | [
"Plot",
"a",
"painting",
"of",
"shared",
"haplotype",
"prefixes",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L98-L148 |
1,083 | cggh/scikit-allel | allel/stats/selection.py | fig_voight_painting | def fig_voight_painting(h, index=None, palette='colorblind',
height_factor=0.01, fig=None):
"""Make a figure of shared haplotype prefixes for both left and right
flanks, centred on some variant of choice.
Parameters
----------
h : array_like, int, shape (n_variants, n_haplot... | python | def fig_voight_painting(h, index=None, palette='colorblind',
height_factor=0.01, fig=None):
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
import seaborn as sns
# check inputs
h = asarray_ndim(h, 2)
if index is None:
# use midpoint
... | [
"def",
"fig_voight_painting",
"(",
"h",
",",
"index",
"=",
"None",
",",
"palette",
"=",
"'colorblind'",
",",
"height_factor",
"=",
"0.01",
",",
"fig",
"=",
"None",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"from",
"matplotlib",
".",
"... | Make a figure of shared haplotype prefixes for both left and right
flanks, centred on some variant of choice.
Parameters
----------
h : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array.
index : int, optional
Index of the variant within the haplotype array to centre ... | [
"Make",
"a",
"figure",
"of",
"shared",
"haplotype",
"prefixes",
"for",
"both",
"left",
"and",
"right",
"flanks",
"centred",
"on",
"some",
"variant",
"of",
"choice",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L151-L251 |
1,084 | cggh/scikit-allel | allel/stats/selection.py | compute_ihh_gaps | def compute_ihh_gaps(pos, map_pos, gap_scale, max_gap, is_accessible):
"""Compute spacing between variants for integrating haplotype
homozygosity.
Parameters
----------
pos : array_like, int, shape (n_variants,)
Variant positions (physical distance).
map_pos : array_like, float, shape (... | python | def compute_ihh_gaps(pos, map_pos, gap_scale, max_gap, is_accessible):
# check inputs
if map_pos is None:
# integrate over physical distance
map_pos = pos
else:
map_pos = asarray_ndim(map_pos, 1)
check_dim0_aligned(pos, map_pos)
# compute physical gaps
physical_gaps ... | [
"def",
"compute_ihh_gaps",
"(",
"pos",
",",
"map_pos",
",",
"gap_scale",
",",
"max_gap",
",",
"is_accessible",
")",
":",
"# check inputs",
"if",
"map_pos",
"is",
"None",
":",
"# integrate over physical distance",
"map_pos",
"=",
"pos",
"else",
":",
"map_pos",
"=... | Compute spacing between variants for integrating haplotype
homozygosity.
Parameters
----------
pos : array_like, int, shape (n_variants,)
Variant positions (physical distance).
map_pos : array_like, float, shape (n_variants,)
Variant positions (genetic map distance).
gap_scale :... | [
"Compute",
"spacing",
"between",
"variants",
"for",
"integrating",
"haplotype",
"homozygosity",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L255-L322 |
1,085 | cggh/scikit-allel | allel/stats/selection.py | xpnsl | def xpnsl(h1, h2, use_threads=True):
"""Cross-population version of the NSL statistic.
Parameters
----------
h1 : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array for the first population.
h2 : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array for th... | python | def xpnsl(h1, h2, use_threads=True):
# check inputs
h1 = asarray_ndim(h1, 2)
check_integer_dtype(h1)
h2 = asarray_ndim(h2, 2)
check_integer_dtype(h2)
check_dim0_aligned(h1, h2)
h1 = memoryview_safe(h1)
h2 = memoryview_safe(h2)
if use_threads and multiprocessing.cpu_count() > 1:
... | [
"def",
"xpnsl",
"(",
"h1",
",",
"h2",
",",
"use_threads",
"=",
"True",
")",
":",
"# check inputs",
"h1",
"=",
"asarray_ndim",
"(",
"h1",
",",
"2",
")",
"check_integer_dtype",
"(",
"h1",
")",
"h2",
"=",
"asarray_ndim",
"(",
"h2",
",",
"2",
")",
"check... | Cross-population version of the NSL statistic.
Parameters
----------
h1 : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array for the first population.
h2 : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array for the second population.
use_threads : bool,... | [
"Cross",
"-",
"population",
"version",
"of",
"the",
"NSL",
"statistic",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L661-L736 |
1,086 | cggh/scikit-allel | allel/stats/selection.py | haplotype_diversity | def haplotype_diversity(h):
"""Estimate haplotype diversity.
Parameters
----------
h : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array.
Returns
-------
hd : float
Haplotype diversity.
"""
# check inputs
h = HaplotypeArray(h, copy=False)
... | python | def haplotype_diversity(h):
# check inputs
h = HaplotypeArray(h, copy=False)
# number of haplotypes
n = h.n_haplotypes
# compute haplotype frequencies
f = h.distinct_frequencies()
# estimate haplotype diversity
hd = (1 - np.sum(f**2)) * n / (n - 1)
return hd | [
"def",
"haplotype_diversity",
"(",
"h",
")",
":",
"# check inputs",
"h",
"=",
"HaplotypeArray",
"(",
"h",
",",
"copy",
"=",
"False",
")",
"# number of haplotypes",
"n",
"=",
"h",
".",
"n_haplotypes",
"# compute haplotype frequencies",
"f",
"=",
"h",
".",
"dist... | Estimate haplotype diversity.
Parameters
----------
h : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array.
Returns
-------
hd : float
Haplotype diversity. | [
"Estimate",
"haplotype",
"diversity",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L739-L766 |
1,087 | cggh/scikit-allel | allel/stats/selection.py | moving_haplotype_diversity | def moving_haplotype_diversity(h, size, start=0, stop=None, step=None):
"""Estimate haplotype diversity in moving windows.
Parameters
----------
h : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array.
size : int
The window size (number of variants).
start : int, o... | python | def moving_haplotype_diversity(h, size, start=0, stop=None, step=None):
hd = moving_statistic(values=h, statistic=haplotype_diversity, size=size,
start=start, stop=stop, step=step)
return hd | [
"def",
"moving_haplotype_diversity",
"(",
"h",
",",
"size",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"None",
")",
":",
"hd",
"=",
"moving_statistic",
"(",
"values",
"=",
"h",
",",
"statistic",
"=",
"haplotype_diversity",
",",
... | Estimate haplotype diversity in moving windows.
Parameters
----------
h : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array.
size : int
The window size (number of variants).
start : int, optional
The index at which to start.
stop : int, optional
T... | [
"Estimate",
"haplotype",
"diversity",
"in",
"moving",
"windows",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L769-L795 |
1,088 | cggh/scikit-allel | allel/stats/selection.py | plot_haplotype_frequencies | def plot_haplotype_frequencies(h, palette='Paired', singleton_color='w',
ax=None):
"""Plot haplotype frequencies.
Parameters
----------
h : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array.
palette : string, optional
A Seaborn palette ... | python | def plot_haplotype_frequencies(h, palette='Paired', singleton_color='w',
ax=None):
import matplotlib.pyplot as plt
import seaborn as sns
# check inputs
h = HaplotypeArray(h, copy=False)
# setup figure
if ax is None:
width = plt.rcParams['figure.figsize'][... | [
"def",
"plot_haplotype_frequencies",
"(",
"h",
",",
"palette",
"=",
"'Paired'",
",",
"singleton_color",
"=",
"'w'",
",",
"ax",
"=",
"None",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"seaborn",
"as",
"sns",
"# check inputs",
"h",... | Plot haplotype frequencies.
Parameters
----------
h : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array.
palette : string, optional
A Seaborn palette name.
singleton_color : string, optional
Color to paint singleton haplotypes.
ax : axes, optional
... | [
"Plot",
"haplotype",
"frequencies",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L888-L945 |
1,089 | cggh/scikit-allel | allel/stats/selection.py | moving_hfs_rank | def moving_hfs_rank(h, size, start=0, stop=None):
"""Helper function for plotting haplotype frequencies in moving windows.
Parameters
----------
h : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array.
size : int
The window size (number of variants).
start : int, o... | python | def moving_hfs_rank(h, size, start=0, stop=None):
# determine windows
windows = np.asarray(list(index_windows(h, size=size, start=start,
stop=stop, step=None)))
# setup output
hr = np.zeros((windows.shape[0], h.shape[1]), dtype='i4')
# iterate over windo... | [
"def",
"moving_hfs_rank",
"(",
"h",
",",
"size",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
")",
":",
"# determine windows",
"windows",
"=",
"np",
".",
"asarray",
"(",
"list",
"(",
"index_windows",
"(",
"h",
",",
"size",
"=",
"size",
",",
"sta... | Helper function for plotting haplotype frequencies in moving windows.
Parameters
----------
h : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array.
size : int
The window size (number of variants).
start : int, optional
The index at which to start.
stop : i... | [
"Helper",
"function",
"for",
"plotting",
"haplotype",
"frequencies",
"in",
"moving",
"windows",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L948-L996 |
1,090 | cggh/scikit-allel | allel/stats/selection.py | plot_moving_haplotype_frequencies | def plot_moving_haplotype_frequencies(pos, h, size, start=0, stop=None, n=None,
palette='Paired', singleton_color='w',
ax=None):
"""Plot haplotype frequencies in moving windows over the genome.
Parameters
----------
pos : array... | python | def plot_moving_haplotype_frequencies(pos, h, size, start=0, stop=None, n=None,
palette='Paired', singleton_color='w',
ax=None):
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
# setup figure
... | [
"def",
"plot_moving_haplotype_frequencies",
"(",
"pos",
",",
"h",
",",
"size",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"n",
"=",
"None",
",",
"palette",
"=",
"'Paired'",
",",
"singleton_color",
"=",
"'w'",
",",
"ax",
"=",
"None",
")",
... | Plot haplotype frequencies in moving windows over the genome.
Parameters
----------
pos : array_like, int, shape (n_items,)
Variant positions, using 1-based coordinates, in ascending order.
h : array_like, int, shape (n_variants, n_haplotypes)
Haplotype array.
size : int
The... | [
"Plot",
"haplotype",
"frequencies",
"in",
"moving",
"windows",
"over",
"the",
"genome",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L999-L1070 |
1,091 | cggh/scikit-allel | allel/stats/selection.py | moving_delta_tajima_d | def moving_delta_tajima_d(ac1, ac2, size, start=0, stop=None, step=None):
"""Compute the difference in Tajima's D between two populations in
moving windows.
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array for the first population.
ac2 : arr... | python | def moving_delta_tajima_d(ac1, ac2, size, start=0, stop=None, step=None):
d1 = moving_tajima_d(ac1, size=size, start=start, stop=stop, step=step)
d2 = moving_tajima_d(ac2, size=size, start=start, stop=stop, step=step)
delta = d1 - d2
delta_z = (delta - np.mean(delta)) / np.std(delta)
return delta_z | [
"def",
"moving_delta_tajima_d",
"(",
"ac1",
",",
"ac2",
",",
"size",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"None",
")",
":",
"d1",
"=",
"moving_tajima_d",
"(",
"ac1",
",",
"size",
"=",
"size",
",",
"start",
"=",
"start... | Compute the difference in Tajima's D between two populations in
moving windows.
Parameters
----------
ac1 : array_like, int, shape (n_variants, n_alleles)
Allele counts array for the first population.
ac2 : array_like, int, shape (n_variants, n_alleles)
Allele counts array for the s... | [
"Compute",
"the",
"difference",
"in",
"Tajima",
"s",
"D",
"between",
"two",
"populations",
"in",
"moving",
"windows",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L1073-L1108 |
1,092 | cggh/scikit-allel | allel/stats/selection.py | make_similar_sized_bins | def make_similar_sized_bins(x, n):
"""Utility function to create a set of bins over the range of values in `x`
such that each bin contains roughly the same number of values.
Parameters
----------
x : array_like
The values to be binned.
n : int
The number of bins to create.
... | python | def make_similar_sized_bins(x, n):
# copy and sort the array
y = np.array(x).flatten()
y.sort()
# setup bins
bins = [y[0]]
# determine step size
step = len(y) // n
# add bin edges
for i in range(step, len(y), step):
# get value at this index
v = y[i]
# on... | [
"def",
"make_similar_sized_bins",
"(",
"x",
",",
"n",
")",
":",
"# copy and sort the array",
"y",
"=",
"np",
".",
"array",
"(",
"x",
")",
".",
"flatten",
"(",
")",
"y",
".",
"sort",
"(",
")",
"# setup bins",
"bins",
"=",
"[",
"y",
"[",
"0",
"]",
"]... | Utility function to create a set of bins over the range of values in `x`
such that each bin contains roughly the same number of values.
Parameters
----------
x : array_like
The values to be binned.
n : int
The number of bins to create.
Returns
-------
bins : ndarray
... | [
"Utility",
"function",
"to",
"create",
"a",
"set",
"of",
"bins",
"over",
"the",
"range",
"of",
"values",
"in",
"x",
"such",
"that",
"each",
"bin",
"contains",
"roughly",
"the",
"same",
"number",
"of",
"values",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L1111-L1157 |
1,093 | cggh/scikit-allel | allel/stats/selection.py | standardize | def standardize(score):
"""Centre and scale to unit variance."""
score = asarray_ndim(score, 1)
return (score - np.nanmean(score)) / np.nanstd(score) | python | def standardize(score):
score = asarray_ndim(score, 1)
return (score - np.nanmean(score)) / np.nanstd(score) | [
"def",
"standardize",
"(",
"score",
")",
":",
"score",
"=",
"asarray_ndim",
"(",
"score",
",",
"1",
")",
"return",
"(",
"score",
"-",
"np",
".",
"nanmean",
"(",
"score",
")",
")",
"/",
"np",
".",
"nanstd",
"(",
"score",
")"
] | Centre and scale to unit variance. | [
"Centre",
"and",
"scale",
"to",
"unit",
"variance",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L1160-L1163 |
1,094 | cggh/scikit-allel | allel/stats/selection.py | standardize_by_allele_count | def standardize_by_allele_count(score, aac, bins=None, n_bins=None,
diagnostics=True):
"""Standardize `score` within allele frequency bins.
Parameters
----------
score : array_like, float
The score to be standardized, e.g., IHS or NSL.
aac : array_like, int
... | python | def standardize_by_allele_count(score, aac, bins=None, n_bins=None,
diagnostics=True):
from scipy.stats import binned_statistic
# check inputs
score = asarray_ndim(score, 1)
aac = asarray_ndim(aac, 1)
check_dim0_aligned(score, aac)
# remove nans
nonan = ~np.... | [
"def",
"standardize_by_allele_count",
"(",
"score",
",",
"aac",
",",
"bins",
"=",
"None",
",",
"n_bins",
"=",
"None",
",",
"diagnostics",
"=",
"True",
")",
":",
"from",
"scipy",
".",
"stats",
"import",
"binned_statistic",
"# check inputs",
"score",
"=",
"asa... | Standardize `score` within allele frequency bins.
Parameters
----------
score : array_like, float
The score to be standardized, e.g., IHS or NSL.
aac : array_like, int
An array of alternate allele counts.
bins : array_like, int, optional
Allele count bins, overrides `n_bins`... | [
"Standardize",
"score",
"within",
"allele",
"frequency",
"bins",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L1166-L1260 |
1,095 | cggh/scikit-allel | allel/stats/window.py | moving_statistic | def moving_statistic(values, statistic, size, start=0, stop=None, step=None, **kwargs):
"""Calculate a statistic in a moving window over `values`.
Parameters
----------
values : array_like
The data to summarise.
statistic : function
The statistic to compute within each window.
... | python | def moving_statistic(values, statistic, size, start=0, stop=None, step=None, **kwargs):
windows = index_windows(values, size, start, stop, step)
# setup output
out = np.array([statistic(values[i:j], **kwargs) for i, j in windows])
return out | [
"def",
"moving_statistic",
"(",
"values",
",",
"statistic",
",",
"size",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"windows",
"=",
"index_windows",
"(",
"values",
",",
"size",
",",
... | Calculate a statistic in a moving window over `values`.
Parameters
----------
values : array_like
The data to summarise.
statistic : function
The statistic to compute within each window.
size : int
The window size (number of values).
start : int, optional
The in... | [
"Calculate",
"a",
"statistic",
"in",
"a",
"moving",
"window",
"over",
"values",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/window.py#L12-L57 |
1,096 | cggh/scikit-allel | allel/stats/window.py | window_locations | def window_locations(pos, windows):
"""Locate indices in `pos` corresponding to the start and stop positions
of `windows`.
"""
start_locs = np.searchsorted(pos, windows[:, 0])
stop_locs = np.searchsorted(pos, windows[:, 1], side='right')
locs = np.column_stack((start_locs, stop_locs))
retur... | python | def window_locations(pos, windows):
start_locs = np.searchsorted(pos, windows[:, 0])
stop_locs = np.searchsorted(pos, windows[:, 1], side='right')
locs = np.column_stack((start_locs, stop_locs))
return locs | [
"def",
"window_locations",
"(",
"pos",
",",
"windows",
")",
":",
"start_locs",
"=",
"np",
".",
"searchsorted",
"(",
"pos",
",",
"windows",
"[",
":",
",",
"0",
"]",
")",
"stop_locs",
"=",
"np",
".",
"searchsorted",
"(",
"pos",
",",
"windows",
"[",
":"... | Locate indices in `pos` corresponding to the start and stop positions
of `windows`. | [
"Locate",
"indices",
"in",
"pos",
"corresponding",
"to",
"the",
"start",
"and",
"stop",
"positions",
"of",
"windows",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/window.py#L135-L143 |
1,097 | cggh/scikit-allel | allel/stats/window.py | per_base | def per_base(x, windows, is_accessible=None, fill=np.nan):
"""Calculate the per-base value of a windowed statistic.
Parameters
----------
x : array_like, shape (n_windows,)
The statistic to average per-base.
windows : array_like, int, shape (n_windows, 2)
The windows used, as an ar... | python | def per_base(x, windows, is_accessible=None, fill=np.nan):
# calculate window sizes
if is_accessible is None:
# N.B., window stops are included
n_bases = np.diff(windows, axis=1).reshape(-1) + 1
else:
n_bases = np.array([np.count_nonzero(is_accessible[i-1:j])
... | [
"def",
"per_base",
"(",
"x",
",",
"windows",
",",
"is_accessible",
"=",
"None",
",",
"fill",
"=",
"np",
".",
"nan",
")",
":",
"# calculate window sizes",
"if",
"is_accessible",
"is",
"None",
":",
"# N.B., window stops are included",
"n_bases",
"=",
"np",
".",
... | Calculate the per-base value of a windowed statistic.
Parameters
----------
x : array_like, shape (n_windows,)
The statistic to average per-base.
windows : array_like, int, shape (n_windows, 2)
The windows used, as an array of (window_start, window_stop)
positions using 1-based... | [
"Calculate",
"the",
"per",
"-",
"base",
"value",
"of",
"a",
"windowed",
"statistic",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/window.py#L379-L431 |
1,098 | cggh/scikit-allel | allel/stats/window.py | equally_accessible_windows | def equally_accessible_windows(is_accessible, size, start=0, stop=None, step=None):
"""Create windows each containing the same number of accessible bases.
Parameters
----------
is_accessible : array_like, bool, shape (n_bases,)
Array defining accessible status of all bases on a contig/chromosom... | python | def equally_accessible_windows(is_accessible, size, start=0, stop=None, step=None):
pos_accessible, = np.nonzero(is_accessible)
pos_accessible += 1 # convert to 1-based coordinates
# N.B., need some care in handling start and stop positions, these are
# genomic positions at which to start and stop the... | [
"def",
"equally_accessible_windows",
"(",
"is_accessible",
",",
"size",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"None",
")",
":",
"pos_accessible",
",",
"=",
"np",
".",
"nonzero",
"(",
"is_accessible",
")",
"pos_accessible",
"+=... | Create windows each containing the same number of accessible bases.
Parameters
----------
is_accessible : array_like, bool, shape (n_bases,)
Array defining accessible status of all bases on a contig/chromosome.
size : int
Window size (number of accessible bases).
start : int, option... | [
"Create",
"windows",
"each",
"containing",
"the",
"same",
"number",
"of",
"accessible",
"bases",
"."
] | 3c979a57a100240ba959dd13f98839349530f215 | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/window.py#L434-L472 |
1,099 | bartTC/django-attachments | attachments/templatetags/attachments_tags.py | attachment_form | def attachment_form(context, obj):
"""
Renders a "upload attachment" form.
The user must own ``attachments.add_attachment permission`` to add
attachments.
"""
if context['user'].has_perm('attachments.add_attachment'):
return {
'form': AttachmentForm(),
'form_url'... | python | def attachment_form(context, obj):
if context['user'].has_perm('attachments.add_attachment'):
return {
'form': AttachmentForm(),
'form_url': add_url_for_obj(obj),
'next': context.request.build_absolute_uri(),
}
else:
return {'form': None} | [
"def",
"attachment_form",
"(",
"context",
",",
"obj",
")",
":",
"if",
"context",
"[",
"'user'",
"]",
".",
"has_perm",
"(",
"'attachments.add_attachment'",
")",
":",
"return",
"{",
"'form'",
":",
"AttachmentForm",
"(",
")",
",",
"'form_url'",
":",
"add_url_fo... | Renders a "upload attachment" form.
The user must own ``attachments.add_attachment permission`` to add
attachments. | [
"Renders",
"a",
"upload",
"attachment",
"form",
"."
] | 012b7168f9342e07683a54ceab57696e0072962e | https://github.com/bartTC/django-attachments/blob/012b7168f9342e07683a54ceab57696e0072962e/attachments/templatetags/attachments_tags.py#L12-L26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.