repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
moonso/loqusdb
loqusdb/plugins/mongo/variant.py
VariantMixin.add_variants
def add_variants(self, variants): """Add a bulk of variants This could be used for faster inserts Args: variants(iterable(dict)) """ operations = [] nr_inserted = 0 for i,variant in enumerate(variants, 1): ...
python
def add_variants(self, variants): """Add a bulk of variants This could be used for faster inserts Args: variants(iterable(dict)) """ operations = [] nr_inserted = 0 for i,variant in enumerate(variants, 1): ...
[ "def", "add_variants", "(", "self", ",", "variants", ")", ":", "operations", "=", "[", "]", "nr_inserted", "=", "0", "for", "i", ",", "variant", "in", "enumerate", "(", "variants", ",", "1", ")", ":", "# We need to check if there was any information returned", ...
Add a bulk of variants This could be used for faster inserts Args: variants(iterable(dict))
[ "Add", "a", "bulk", "of", "variants", "This", "could", "be", "used", "for", "faster", "inserts", "Args", ":", "variants", "(", "iterable", "(", "dict", "))" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/variant.py#L70-L104
moonso/loqusdb
loqusdb/plugins/mongo/variant.py
VariantMixin.search_variants
def search_variants(self, variant_ids): """Make a batch search for variants in the database Args: variant_ids(list(str)): List of variant ids Returns: res(pymngo.Cursor(variant_obj)): The result """ query = {'_id': {'$in': variant_ids}} ...
python
def search_variants(self, variant_ids): """Make a batch search for variants in the database Args: variant_ids(list(str)): List of variant ids Returns: res(pymngo.Cursor(variant_obj)): The result """ query = {'_id': {'$in': variant_ids}} ...
[ "def", "search_variants", "(", "self", ",", "variant_ids", ")", ":", "query", "=", "{", "'_id'", ":", "{", "'$in'", ":", "variant_ids", "}", "}", "return", "self", ".", "db", ".", "variant", ".", "find", "(", "query", ")" ]
Make a batch search for variants in the database Args: variant_ids(list(str)): List of variant ids Returns: res(pymngo.Cursor(variant_obj)): The result
[ "Make", "a", "batch", "search", "for", "variants", "in", "the", "database", "Args", ":", "variant_ids", "(", "list", "(", "str", "))", ":", "List", "of", "variant", "ids", "Returns", ":", "res", "(", "pymngo", ".", "Cursor", "(", "variant_obj", "))", "...
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/variant.py#L123-L134
moonso/loqusdb
loqusdb/plugins/mongo/variant.py
VariantMixin.get_variants
def get_variants(self, chromosome=None, start=None, end=None): """Return all variants in the database If no region is specified all variants will be returned. Args: chromosome(str) start(int) end(int) Returns: variants(Iterab...
python
def get_variants(self, chromosome=None, start=None, end=None): """Return all variants in the database If no region is specified all variants will be returned. Args: chromosome(str) start(int) end(int) Returns: variants(Iterab...
[ "def", "get_variants", "(", "self", ",", "chromosome", "=", "None", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "query", "=", "{", "}", "if", "chromosome", ":", "query", "[", "'chrom'", "]", "=", "chromosome", "if", "start", ":", ...
Return all variants in the database If no region is specified all variants will be returned. Args: chromosome(str) start(int) end(int) Returns: variants(Iterable(Variant))
[ "Return", "all", "variants", "in", "the", "database", "If", "no", "region", "is", "specified", "all", "variants", "will", "be", "returned", "." ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/variant.py#L137-L157
moonso/loqusdb
loqusdb/plugins/mongo/variant.py
VariantMixin.delete_variant
def delete_variant(self, variant): """Delete observation in database This means that we take down the observations variable with one. If 'observations' == 1 we remove the variant. If variant was homozygote we decrease 'homozygote' with one. Also remove the family from array 'fam...
python
def delete_variant(self, variant): """Delete observation in database This means that we take down the observations variable with one. If 'observations' == 1 we remove the variant. If variant was homozygote we decrease 'homozygote' with one. Also remove the family from array 'fam...
[ "def", "delete_variant", "(", "self", ",", "variant", ")", ":", "mongo_variant", "=", "self", ".", "get_variant", "(", "variant", ")", "if", "mongo_variant", ":", "if", "mongo_variant", "[", "'observations'", "]", "==", "1", ":", "LOG", ".", "debug", "(", ...
Delete observation in database This means that we take down the observations variable with one. If 'observations' == 1 we remove the variant. If variant was homozygote we decrease 'homozygote' with one. Also remove the family from array 'families'. Args: variant (di...
[ "Delete", "observation", "in", "database" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/variant.py#L159-L196
moonso/loqusdb
loqusdb/plugins/mongo/variant.py
VariantMixin.get_chromosomes
def get_chromosomes(self, sv=False): """Return a list of all chromosomes found in database Args: sv(bool): if sv variants should be choosen Returns: res(iterable(str)): An iterable with all chromosomes in the database """ if sv: ...
python
def get_chromosomes(self, sv=False): """Return a list of all chromosomes found in database Args: sv(bool): if sv variants should be choosen Returns: res(iterable(str)): An iterable with all chromosomes in the database """ if sv: ...
[ "def", "get_chromosomes", "(", "self", ",", "sv", "=", "False", ")", ":", "if", "sv", ":", "res", "=", "self", ".", "db", ".", "structural_variant", ".", "distinct", "(", "'chrom'", ")", "else", ":", "res", "=", "self", ".", "db", ".", "variant", "...
Return a list of all chromosomes found in database Args: sv(bool): if sv variants should be choosen Returns: res(iterable(str)): An iterable with all chromosomes in the database
[ "Return", "a", "list", "of", "all", "chromosomes", "found", "in", "database", "Args", ":", "sv", "(", "bool", ")", ":", "if", "sv", "variants", "should", "be", "choosen", "Returns", ":", "res", "(", "iterable", "(", "str", "))", ":", "An", "iterable", ...
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/variant.py#L199-L213
moonso/loqusdb
loqusdb/plugins/mongo/variant.py
VariantMixin.get_max_position
def get_max_position(self, chrom): """Get the last position observed on a chromosome in the database Args: chrom(str) Returns: end(int): The largest end position found """ res = self.db.variant.find({'chrom':chrom}, {'_id':0,...
python
def get_max_position(self, chrom): """Get the last position observed on a chromosome in the database Args: chrom(str) Returns: end(int): The largest end position found """ res = self.db.variant.find({'chrom':chrom}, {'_id':0,...
[ "def", "get_max_position", "(", "self", ",", "chrom", ")", ":", "res", "=", "self", ".", "db", ".", "variant", ".", "find", "(", "{", "'chrom'", ":", "chrom", "}", ",", "{", "'_id'", ":", "0", ",", "'end'", ":", "1", "}", ")", ".", "sort", "(",...
Get the last position observed on a chromosome in the database Args: chrom(str) Returns: end(int): The largest end position found
[ "Get", "the", "last", "position", "observed", "on", "a", "chromosome", "in", "the", "database", "Args", ":", "chrom", "(", "str", ")", "Returns", ":", "end", "(", "int", ")", ":", "The", "largest", "end", "position", "found" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/variant.py#L215-L229
moonso/loqusdb
loqusdb/commands/restore.py
restore
def restore(ctx, filename): """Restore the database from a zipped file. Default is to restore from db dump in loqusdb/resources/ """ filename = filename or background_path if not os.path.isfile(filename): LOG.warning("File {} does not exist. Please point to a valid file".format(filename...
python
def restore(ctx, filename): """Restore the database from a zipped file. Default is to restore from db dump in loqusdb/resources/ """ filename = filename or background_path if not os.path.isfile(filename): LOG.warning("File {} does not exist. Please point to a valid file".format(filename...
[ "def", "restore", "(", "ctx", ",", "filename", ")", ":", "filename", "=", "filename", "or", "background_path", "if", "not", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "LOG", ".", "warning", "(", "\"File {} does not exist. Please point to a va...
Restore the database from a zipped file. Default is to restore from db dump in loqusdb/resources/
[ "Restore", "the", "database", "from", "a", "zipped", "file", ".", "Default", "is", "to", "restore", "from", "db", "dump", "in", "loqusdb", "/", "resources", "/" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/restore.py#L21-L42
yjzhang/uncurl_python
uncurl/sampling.py
downsample
def downsample(data, percent): """ downsample the data by removing a given percentage of the reads. Args: data: genes x cells array or sparse matrix percent: float between 0 and 1 """ n_genes = data.shape[0] n_cells = data.shape[1] new_data = data.copy() total_count = fl...
python
def downsample(data, percent): """ downsample the data by removing a given percentage of the reads. Args: data: genes x cells array or sparse matrix percent: float between 0 and 1 """ n_genes = data.shape[0] n_cells = data.shape[1] new_data = data.copy() total_count = fl...
[ "def", "downsample", "(", "data", ",", "percent", ")", ":", "n_genes", "=", "data", ".", "shape", "[", "0", "]", "n_cells", "=", "data", ".", "shape", "[", "1", "]", "new_data", "=", "data", ".", "copy", "(", ")", "total_count", "=", "float", "(", ...
downsample the data by removing a given percentage of the reads. Args: data: genes x cells array or sparse matrix percent: float between 0 and 1
[ "downsample", "the", "data", "by", "removing", "a", "given", "percentage", "of", "the", "reads", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/sampling.py#L7-L34
yjzhang/uncurl_python
uncurl/nb_state_estimation.py
_create_w_objective
def _create_w_objective(m, X, R): """ Creates an objective function and its derivative for W, given M and X (data) Args: m (array): genes x clusters X (array): genes x cells R (array): 1 x genes """ genes, clusters = m.shape cells = X.shape[1] R1 = R.reshape((genes, ...
python
def _create_w_objective(m, X, R): """ Creates an objective function and its derivative for W, given M and X (data) Args: m (array): genes x clusters X (array): genes x cells R (array): 1 x genes """ genes, clusters = m.shape cells = X.shape[1] R1 = R.reshape((genes, ...
[ "def", "_create_w_objective", "(", "m", ",", "X", ",", "R", ")", ":", "genes", ",", "clusters", "=", "m", ".", "shape", "cells", "=", "X", ".", "shape", "[", "1", "]", "R1", "=", "R", ".", "reshape", "(", "(", "genes", ",", "1", ")", ")", "."...
Creates an objective function and its derivative for W, given M and X (data) Args: m (array): genes x clusters X (array): genes x cells R (array): 1 x genes
[ "Creates", "an", "objective", "function", "and", "its", "derivative", "for", "W", "given", "M", "and", "X", "(", "data", ")" ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nb_state_estimation.py#L12-L42
yjzhang/uncurl_python
uncurl/nb_state_estimation.py
nb_estimate_state
def nb_estimate_state(data, clusters, R=None, init_means=None, init_weights=None, max_iters=10, tol=1e-4, disp=True, inner_max_iters=400, normalize=True): """ Uses a Negative Binomial Mixture model to estimate cell states and cell state mixing weights. If some of the genes do not fit a negative binomia...
python
def nb_estimate_state(data, clusters, R=None, init_means=None, init_weights=None, max_iters=10, tol=1e-4, disp=True, inner_max_iters=400, normalize=True): """ Uses a Negative Binomial Mixture model to estimate cell states and cell state mixing weights. If some of the genes do not fit a negative binomia...
[ "def", "nb_estimate_state", "(", "data", ",", "clusters", ",", "R", "=", "None", ",", "init_means", "=", "None", ",", "init_weights", "=", "None", ",", "max_iters", "=", "10", ",", "tol", "=", "1e-4", ",", "disp", "=", "True", ",", "inner_max_iters", "...
Uses a Negative Binomial Mixture model to estimate cell states and cell state mixing weights. If some of the genes do not fit a negative binomial distribution (mean > var), then the genes are discarded from the analysis. Args: data (array): genes x cells clusters (int): number of mixtu...
[ "Uses", "a", "Negative", "Binomial", "Mixture", "model", "to", "estimate", "cell", "states", "and", "cell", "state", "mixing", "weights", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nb_state_estimation.py#L71-L147
yjzhang/uncurl_python
uncurl/lightlda_utils.py
poisson_objective
def poisson_objective(X, m, w): """ Creates an objective function and its derivative for M, given W and X Args: w (array): clusters x cells X (array): genes x cells selected_genes (array): array of ints - genes to be selected """ clusters, cells = w.shape genes = X.shape[...
python
def poisson_objective(X, m, w): """ Creates an objective function and its derivative for M, given W and X Args: w (array): clusters x cells X (array): genes x cells selected_genes (array): array of ints - genes to be selected """ clusters, cells = w.shape genes = X.shape[...
[ "def", "poisson_objective", "(", "X", ",", "m", ",", "w", ")", ":", "clusters", ",", "cells", "=", "w", ".", "shape", "genes", "=", "X", ".", "shape", "[", "0", "]", "#m = m.reshape((X.shape[0], w.shape[0]))", "d", "=", "m", ".", "dot", "(", "w", ")"...
Creates an objective function and its derivative for M, given W and X Args: w (array): clusters x cells X (array): genes x cells selected_genes (array): array of ints - genes to be selected
[ "Creates", "an", "objective", "function", "and", "its", "derivative", "for", "M", "given", "W", "and", "X", "Args", ":", "w", "(", "array", ")", ":", "clusters", "x", "cells", "X", "(", "array", ")", ":", "genes", "x", "cells", "selected_genes", "(", ...
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/lightlda_utils.py#L114-L130
yjzhang/uncurl_python
uncurl/lightlda_utils.py
lightlda_estimate_state
def lightlda_estimate_state(data, k, input_folder="data1/LightLDA_input", threads=8, max_iters=250, prepare_data=True, init_means=None, init_weights=None, lightlda_folder=None, data_capacity=1000): """ Runs LDA on the given dataset (can be an 2-D array of any form - sparse or dense, as long as it can be ind...
python
def lightlda_estimate_state(data, k, input_folder="data1/LightLDA_input", threads=8, max_iters=250, prepare_data=True, init_means=None, init_weights=None, lightlda_folder=None, data_capacity=1000): """ Runs LDA on the given dataset (can be an 2-D array of any form - sparse or dense, as long as it can be ind...
[ "def", "lightlda_estimate_state", "(", "data", ",", "k", ",", "input_folder", "=", "\"data1/LightLDA_input\"", ",", "threads", "=", "8", ",", "max_iters", "=", "250", ",", "prepare_data", "=", "True", ",", "init_means", "=", "None", ",", "init_weights", "=", ...
Runs LDA on the given dataset (can be an 2-D array of any form - sparse or dense, as long as it can be indexed). If the data has not already been prepared into LDA format, set "prepare_data" to TRUE. If "prepare_data" is FALSE, the method assumes that the data has already been preprocessed into LightLDA...
[ "Runs", "LDA", "on", "the", "given", "dataset", "(", "can", "be", "an", "2", "-", "D", "array", "of", "any", "form", "-", "sparse", "or", "dense", "as", "long", "as", "it", "can", "be", "indexed", ")", ".", "If", "the", "data", "has", "not", "alr...
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/lightlda_utils.py#L133-L195
moonso/loqusdb
scripts/load_files.py
cli
def cli(ctx, directory, uri, verbose, count): """Load all files in a directory.""" # configure root logger to print to STDERR loglevel = "INFO" if verbose: loglevel = "DEBUG" coloredlogs.install(level=loglevel) p = Path(directory) if not p.is_dir(): LOG.warning("{0}...
python
def cli(ctx, directory, uri, verbose, count): """Load all files in a directory.""" # configure root logger to print to STDERR loglevel = "INFO" if verbose: loglevel = "DEBUG" coloredlogs.install(level=loglevel) p = Path(directory) if not p.is_dir(): LOG.warning("{0}...
[ "def", "cli", "(", "ctx", ",", "directory", ",", "uri", ",", "verbose", ",", "count", ")", ":", "# configure root logger to print to STDERR", "loglevel", "=", "\"INFO\"", "if", "verbose", ":", "loglevel", "=", "\"DEBUG\"", "coloredlogs", ".", "install", "(", "...
Load all files in a directory.
[ "Load", "all", "files", "in", "a", "directory", "." ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/scripts/load_files.py#L24-L72
yjzhang/uncurl_python
uncurl/nmf_wrapper.py
nmf_init
def nmf_init(data, clusters, k, init='enhanced'): """ Generates initial M and W given a data set and an array of cluster labels. There are 3 options for init: enhanced - uses EIn-NMF from Gong 2013 basic - uses means for M, assigns W such that the chosen cluster for a given cell has value 0...
python
def nmf_init(data, clusters, k, init='enhanced'): """ Generates initial M and W given a data set and an array of cluster labels. There are 3 options for init: enhanced - uses EIn-NMF from Gong 2013 basic - uses means for M, assigns W such that the chosen cluster for a given cell has value 0...
[ "def", "nmf_init", "(", "data", ",", "clusters", ",", "k", ",", "init", "=", "'enhanced'", ")", ":", "init_m", "=", "np", ".", "zeros", "(", "(", "data", ".", "shape", "[", "0", "]", ",", "k", ")", ")", "if", "sparse", ".", "issparse", "(", "da...
Generates initial M and W given a data set and an array of cluster labels. There are 3 options for init: enhanced - uses EIn-NMF from Gong 2013 basic - uses means for M, assigns W such that the chosen cluster for a given cell has value 0.75 and all others have 0.25/(k-1). nmf - uses means f...
[ "Generates", "initial", "M", "and", "W", "given", "a", "data", "set", "and", "an", "array", "of", "cluster", "labels", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nmf_wrapper.py#L10-L48
yjzhang/uncurl_python
uncurl/nmf_wrapper.py
log_norm_nmf
def log_norm_nmf(data, k, normalize_w=True, return_cost=True, init_weights=None, init_means=None, write_progress_file=None, **kwargs): """ Args: data (array): dense or sparse array with shape (genes, cells) k (int): number of cell types normalize_w (bool, optional): True if W should be n...
python
def log_norm_nmf(data, k, normalize_w=True, return_cost=True, init_weights=None, init_means=None, write_progress_file=None, **kwargs): """ Args: data (array): dense or sparse array with shape (genes, cells) k (int): number of cell types normalize_w (bool, optional): True if W should be n...
[ "def", "log_norm_nmf", "(", "data", ",", "k", ",", "normalize_w", "=", "True", ",", "return_cost", "=", "True", ",", "init_weights", "=", "None", ",", "init_means", "=", "None", ",", "write_progress_file", "=", "None", ",", "*", "*", "kwargs", ")", ":", ...
Args: data (array): dense or sparse array with shape (genes, cells) k (int): number of cell types normalize_w (bool, optional): True if W should be normalized (so that each column sums to 1). Default: True return_cost (bool, optional): True if the NMF objective value (squared error) shou...
[ "Args", ":", "data", "(", "array", ")", ":", "dense", "or", "sparse", "array", "with", "shape", "(", "genes", "cells", ")", "k", "(", "int", ")", ":", "number", "of", "cell", "types", "normalize_w", "(", "bool", "optional", ")", ":", "True", "if", ...
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nmf_wrapper.py#L51-L95
moonso/loqusdb
loqusdb/build_models/variant.py
check_par
def check_par(chrom, pos): """Check if a coordinate is in the PAR region Args: chrom(str) pos(int) Returns: par(bool) """ par = False for interval in PAR.get(chrom,[]): if (pos >= interval[0] and pos <= interval[1]): ...
python
def check_par(chrom, pos): """Check if a coordinate is in the PAR region Args: chrom(str) pos(int) Returns: par(bool) """ par = False for interval in PAR.get(chrom,[]): if (pos >= interval[0] and pos <= interval[1]): ...
[ "def", "check_par", "(", "chrom", ",", "pos", ")", ":", "par", "=", "False", "for", "interval", "in", "PAR", ".", "get", "(", "chrom", ",", "[", "]", ")", ":", "if", "(", "pos", ">=", "interval", "[", "0", "]", "and", "pos", "<=", "interval", "...
Check if a coordinate is in the PAR region Args: chrom(str) pos(int) Returns: par(bool)
[ "Check", "if", "a", "coordinate", "is", "in", "the", "PAR", "region", "Args", ":", "chrom", "(", "str", ")", "pos", "(", "int", ")", "Returns", ":", "par", "(", "bool", ")" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/build_models/variant.py#L16-L32
moonso/loqusdb
loqusdb/build_models/variant.py
get_variant_id
def get_variant_id(variant): """Get a variant id on the format chrom_pos_ref_alt""" variant_id = '_'.join([ str(variant.CHROM), str(variant.POS), str(variant.REF), str(variant.ALT[0]) ] ) return variant_id
python
def get_variant_id(variant): """Get a variant id on the format chrom_pos_ref_alt""" variant_id = '_'.join([ str(variant.CHROM), str(variant.POS), str(variant.REF), str(variant.ALT[0]) ] ) return variant_id
[ "def", "get_variant_id", "(", "variant", ")", ":", "variant_id", "=", "'_'", ".", "join", "(", "[", "str", "(", "variant", ".", "CHROM", ")", ",", "str", "(", "variant", ".", "POS", ")", ",", "str", "(", "variant", ".", "REF", ")", ",", "str", "(...
Get a variant id on the format chrom_pos_ref_alt
[ "Get", "a", "variant", "id", "on", "the", "format", "chrom_pos_ref_alt" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/build_models/variant.py#L35-L44
moonso/loqusdb
loqusdb/build_models/variant.py
is_greater
def is_greater(a,b): """Check if position a is greater than position b This will look at chromosome and position. For example a position where chrom = 2 and pos = 300 is greater than a position where chrom = 1 and pos = 1000 If any of the chromosomes is outside [1-22,X,Y,MT] we can not say...
python
def is_greater(a,b): """Check if position a is greater than position b This will look at chromosome and position. For example a position where chrom = 2 and pos = 300 is greater than a position where chrom = 1 and pos = 1000 If any of the chromosomes is outside [1-22,X,Y,MT] we can not say...
[ "def", "is_greater", "(", "a", ",", "b", ")", ":", "a_chrom", "=", "CHROM_TO_INT", ".", "get", "(", "a", ".", "chrom", ",", "0", ")", "b_chrom", "=", "CHROM_TO_INT", ".", "get", "(", "b", ".", "chrom", ",", "0", ")", "if", "(", "a_chrom", "==", ...
Check if position a is greater than position b This will look at chromosome and position. For example a position where chrom = 2 and pos = 300 is greater than a position where chrom = 1 and pos = 1000 If any of the chromosomes is outside [1-22,X,Y,MT] we can not say which is biggest. ...
[ "Check", "if", "position", "a", "is", "greater", "than", "position", "b", "This", "will", "look", "at", "chromosome", "and", "position", ".", "For", "example", "a", "position", "where", "chrom", "=", "2", "and", "pos", "=", "300", "is", "greater", "than"...
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/build_models/variant.py#L46-L75
moonso/loqusdb
loqusdb/build_models/variant.py
get_coords
def get_coords(variant): """Returns a dictionary with position information Args: variant(cyvcf2.Variant) Returns: coordinates(dict) """ coordinates = { 'chrom': None, 'end_chrom': None, 'sv_length': None, 'sv_type': None, 'pos': None,...
python
def get_coords(variant): """Returns a dictionary with position information Args: variant(cyvcf2.Variant) Returns: coordinates(dict) """ coordinates = { 'chrom': None, 'end_chrom': None, 'sv_length': None, 'sv_type': None, 'pos': None,...
[ "def", "get_coords", "(", "variant", ")", ":", "coordinates", "=", "{", "'chrom'", ":", "None", ",", "'end_chrom'", ":", "None", ",", "'sv_length'", ":", "None", ",", "'sv_type'", ":", "None", ",", "'pos'", ":", "None", ",", "'end'", ":", "None", ",", ...
Returns a dictionary with position information Args: variant(cyvcf2.Variant) Returns: coordinates(dict)
[ "Returns", "a", "dictionary", "with", "position", "information", "Args", ":", "variant", "(", "cyvcf2", ".", "Variant", ")", "Returns", ":", "coordinates", "(", "dict", ")" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/build_models/variant.py#L78-L156
moonso/loqusdb
loqusdb/build_models/variant.py
build_variant
def build_variant(variant, case_obj, case_id=None, gq_treshold=None): """Return a Variant object Take a cyvcf2 formated variant line and return a models.Variant. If criterias are not fullfilled, eg. variant have no gt call or quality is below gq treshold then return None. Args: variant(cy...
python
def build_variant(variant, case_obj, case_id=None, gq_treshold=None): """Return a Variant object Take a cyvcf2 formated variant line and return a models.Variant. If criterias are not fullfilled, eg. variant have no gt call or quality is below gq treshold then return None. Args: variant(cy...
[ "def", "build_variant", "(", "variant", ",", "case_obj", ",", "case_id", "=", "None", ",", "gq_treshold", "=", "None", ")", ":", "variant_obj", "=", "None", "sv", "=", "False", "# Let cyvcf2 tell if it is a Structural Variant or not", "if", "variant", ".", "var_ty...
Return a Variant object Take a cyvcf2 formated variant line and return a models.Variant. If criterias are not fullfilled, eg. variant have no gt call or quality is below gq treshold then return None. Args: variant(cyvcf2.Variant) case_obj(Case): We need the case object to check indivi...
[ "Return", "a", "Variant", "object" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/build_models/variant.py#L158-L247
moonso/loqusdb
loqusdb/commands/migrate.py
migrate
def migrate(ctx,): """Migrate an old loqusdb instance to 1.0 """ adapter = ctx.obj['adapter'] start_time = datetime.now() nr_updated = migrate_database(adapter) LOG.info("All variants updated, time to complete migration: {}".format( datetime.now() - start_time)) LOG.in...
python
def migrate(ctx,): """Migrate an old loqusdb instance to 1.0 """ adapter = ctx.obj['adapter'] start_time = datetime.now() nr_updated = migrate_database(adapter) LOG.info("All variants updated, time to complete migration: {}".format( datetime.now() - start_time)) LOG.in...
[ "def", "migrate", "(", "ctx", ",", ")", ":", "adapter", "=", "ctx", ".", "obj", "[", "'adapter'", "]", "start_time", "=", "datetime", ".", "now", "(", ")", "nr_updated", "=", "migrate_database", "(", "adapter", ")", "LOG", ".", "info", "(", "\"All vari...
Migrate an old loqusdb instance to 1.0
[ "Migrate", "an", "old", "loqusdb", "instance", "to", "1", ".", "0" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/migrate.py#L14-L25
moonso/loqusdb
loqusdb/commands/update.py
update
def update(ctx, variant_file, sv_variants, family_file, family_type, skip_case_id, gq_treshold, case_id, ensure_index, max_window): """Load the variants of a case A variant is loaded if it is observed in any individual of a case If no family file is provided all individuals in vcf file will be ...
python
def update(ctx, variant_file, sv_variants, family_file, family_type, skip_case_id, gq_treshold, case_id, ensure_index, max_window): """Load the variants of a case A variant is loaded if it is observed in any individual of a case If no family file is provided all individuals in vcf file will be ...
[ "def", "update", "(", "ctx", ",", "variant_file", ",", "sv_variants", ",", "family_file", ",", "family_type", ",", "skip_case_id", ",", "gq_treshold", ",", "case_id", ",", "ensure_index", ",", "max_window", ")", ":", "if", "not", "(", "family_file", "or", "c...
Load the variants of a case A variant is loaded if it is observed in any individual of a case If no family file is provided all individuals in vcf file will be considered.
[ "Load", "the", "variants", "of", "a", "case" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/update.py#L62-L114
moonso/loqusdb
loqusdb/commands/export.py
export
def export(ctx, outfile, variant_type): """Export the variants of a loqus db The variants are exported to a vcf file """ adapter = ctx.obj['adapter'] version = ctx.obj['version'] LOG.info("Export the variants from {0}".format(adapter)) nr_cases = 0 is_sv = variant_type...
python
def export(ctx, outfile, variant_type): """Export the variants of a loqus db The variants are exported to a vcf file """ adapter = ctx.obj['adapter'] version = ctx.obj['version'] LOG.info("Export the variants from {0}".format(adapter)) nr_cases = 0 is_sv = variant_type...
[ "def", "export", "(", "ctx", ",", "outfile", ",", "variant_type", ")", ":", "adapter", "=", "ctx", ".", "obj", "[", "'adapter'", "]", "version", "=", "ctx", ".", "obj", "[", "'version'", "]", "LOG", ".", "info", "(", "\"Export the variants from {0}\"", "...
Export the variants of a loqus db The variants are exported to a vcf file
[ "Export", "the", "variants", "of", "a", "loqus", "db", "The", "variants", "are", "exported", "to", "a", "vcf", "file" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/export.py#L28-L97
moonso/loqusdb
loqusdb/utils/load.py
load_database
def load_database(adapter, variant_file=None, sv_file=None, family_file=None, family_type='ped', skip_case_id=False, gq_treshold=None, case_id=None, max_window = 3000, profile_file=None, hard_threshold=0.95, soft_threshold=0.9): """Load the database with a case ...
python
def load_database(adapter, variant_file=None, sv_file=None, family_file=None, family_type='ped', skip_case_id=False, gq_treshold=None, case_id=None, max_window = 3000, profile_file=None, hard_threshold=0.95, soft_threshold=0.9): """Load the database with a case ...
[ "def", "load_database", "(", "adapter", ",", "variant_file", "=", "None", ",", "sv_file", "=", "None", ",", "family_file", "=", "None", ",", "family_type", "=", "'ped'", ",", "skip_case_id", "=", "False", ",", "gq_treshold", "=", "None", ",", "case_id", "=...
Load the database with a case and its variants Args: adapter: Connection to database variant_file(str): Path to variant file sv_file(str): Path to sv variant file family_file(str): Path to family file family_type(str): Format of family file skip_case_id(b...
[ "Load", "the", "database", "with", "a", "case", "and", "its", "variants" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/load.py#L26-L151
moonso/loqusdb
loqusdb/utils/load.py
load_case
def load_case(adapter, case_obj, update=False): """Load a case to the database Args: adapter: Connection to database case_obj: dict update(bool): If existing case should be updated Returns: case_obj(models.Case) """ # Check if the case already exists in database. ...
python
def load_case(adapter, case_obj, update=False): """Load a case to the database Args: adapter: Connection to database case_obj: dict update(bool): If existing case should be updated Returns: case_obj(models.Case) """ # Check if the case already exists in database. ...
[ "def", "load_case", "(", "adapter", ",", "case_obj", ",", "update", "=", "False", ")", ":", "# Check if the case already exists in database.", "existing_case", "=", "adapter", ".", "case", "(", "case_obj", ")", "if", "existing_case", ":", "if", "not", "update", ...
Load a case to the database Args: adapter: Connection to database case_obj: dict update(bool): If existing case should be updated Returns: case_obj(models.Case)
[ "Load", "a", "case", "to", "the", "database" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/load.py#L153-L177
moonso/loqusdb
loqusdb/utils/load.py
load_variants
def load_variants(adapter, vcf_obj, case_obj, skip_case_id=False, gq_treshold=None, max_window=3000, variant_type='snv'): """Load variants for a family into the database. Args: adapter (loqusdb.plugins.Adapter): initialized plugin case_obj(Case): dict with case information ...
python
def load_variants(adapter, vcf_obj, case_obj, skip_case_id=False, gq_treshold=None, max_window=3000, variant_type='snv'): """Load variants for a family into the database. Args: adapter (loqusdb.plugins.Adapter): initialized plugin case_obj(Case): dict with case information ...
[ "def", "load_variants", "(", "adapter", ",", "vcf_obj", ",", "case_obj", ",", "skip_case_id", "=", "False", ",", "gq_treshold", "=", "None", ",", "max_window", "=", "3000", ",", "variant_type", "=", "'snv'", ")", ":", "if", "variant_type", "==", "'snv'", "...
Load variants for a family into the database. Args: adapter (loqusdb.plugins.Adapter): initialized plugin case_obj(Case): dict with case information nr_variants(int) skip_case_id (bool): whether to include the case id on variant level or not gq_t...
[ "Load", "variants", "for", "a", "family", "into", "the", "database", "." ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/load.py#L179-L222
yjzhang/uncurl_python
uncurl/preprocessing.py
sparse_mean_var
def sparse_mean_var(data): """ Calculates the variance for each row of a sparse matrix, using the relationship Var = E[x^2] - E[x]^2. Returns: pair of matrices mean, variance. """ data = sparse.csc_matrix(data) return sparse_means_var_csc(data.data, data.indices, ...
python
def sparse_mean_var(data): """ Calculates the variance for each row of a sparse matrix, using the relationship Var = E[x^2] - E[x]^2. Returns: pair of matrices mean, variance. """ data = sparse.csc_matrix(data) return sparse_means_var_csc(data.data, data.indices, ...
[ "def", "sparse_mean_var", "(", "data", ")", ":", "data", "=", "sparse", ".", "csc_matrix", "(", "data", ")", "return", "sparse_means_var_csc", "(", "data", ".", "data", ",", "data", ".", "indices", ",", "data", ".", "indptr", ",", "data", ".", "shape", ...
Calculates the variance for each row of a sparse matrix, using the relationship Var = E[x^2] - E[x]^2. Returns: pair of matrices mean, variance.
[ "Calculates", "the", "variance", "for", "each", "row", "of", "a", "sparse", "matrix", "using", "the", "relationship", "Var", "=", "E", "[", "x^2", "]", "-", "E", "[", "x", "]", "^2", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/preprocessing.py#L10-L23
yjzhang/uncurl_python
uncurl/preprocessing.py
max_variance_genes
def max_variance_genes(data, nbins=5, frac=0.2): """ This function identifies the genes that have the max variance across a number of bins sorted by mean. Args: data (array): genes x cells nbins (int): number of bins to sort genes by mean expression level. Default: 10. frac (flo...
python
def max_variance_genes(data, nbins=5, frac=0.2): """ This function identifies the genes that have the max variance across a number of bins sorted by mean. Args: data (array): genes x cells nbins (int): number of bins to sort genes by mean expression level. Default: 10. frac (flo...
[ "def", "max_variance_genes", "(", "data", ",", "nbins", "=", "5", ",", "frac", "=", "0.2", ")", ":", "# TODO: profile, make more efficient for large matrices", "# 8000 cells: 0.325 seconds", "# top time: sparse.csc_tocsr, csc_matvec, astype, copy, mul_scalar", "# 73233 cells: 5.347...
This function identifies the genes that have the max variance across a number of bins sorted by mean. Args: data (array): genes x cells nbins (int): number of bins to sort genes by mean expression level. Default: 10. frac (float): fraction of genes to return per bin - between 0 and 1. D...
[ "This", "function", "identifies", "the", "genes", "that", "have", "the", "max", "variance", "across", "a", "number", "of", "bins", "sorted", "by", "mean", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/preprocessing.py#L25-L67
yjzhang/uncurl_python
uncurl/preprocessing.py
cell_normalize
def cell_normalize(data): """ Returns the data where the expression is normalized so that the total count per cell is equal. """ if sparse.issparse(data): data = sparse.csc_matrix(data.astype(float)) # normalize in-place sparse_cell_normalize(data.data, data.i...
python
def cell_normalize(data): """ Returns the data where the expression is normalized so that the total count per cell is equal. """ if sparse.issparse(data): data = sparse.csc_matrix(data.astype(float)) # normalize in-place sparse_cell_normalize(data.data, data.i...
[ "def", "cell_normalize", "(", "data", ")", ":", "if", "sparse", ".", "issparse", "(", "data", ")", ":", "data", "=", "sparse", ".", "csc_matrix", "(", "data", ".", "astype", "(", "float", ")", ")", "# normalize in-place", "sparse_cell_normalize", "(", "dat...
Returns the data where the expression is normalized so that the total count per cell is equal.
[ "Returns", "the", "data", "where", "the", "expression", "is", "normalized", "so", "that", "the", "total", "count", "per", "cell", "is", "equal", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/preprocessing.py#L69-L91
yjzhang/uncurl_python
uncurl/preprocessing.py
log1p
def log1p(data): """ Returns ln(data+1), whether the original data is dense or sparse. """ if sparse.issparse(data): return data.log1p() else: return np.log1p(data)
python
def log1p(data): """ Returns ln(data+1), whether the original data is dense or sparse. """ if sparse.issparse(data): return data.log1p() else: return np.log1p(data)
[ "def", "log1p", "(", "data", ")", ":", "if", "sparse", ".", "issparse", "(", "data", ")", ":", "return", "data", ".", "log1p", "(", ")", "else", ":", "return", "np", ".", "log1p", "(", "data", ")" ]
Returns ln(data+1), whether the original data is dense or sparse.
[ "Returns", "ln", "(", "data", "+", "1", ")", "whether", "the", "original", "data", "is", "dense", "or", "sparse", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/preprocessing.py#L93-L100
moonso/loqusdb
loqusdb/build_models/case.py
get_individual_positions
def get_individual_positions(individuals): """Return a dictionary with individual positions Args: individuals(list): A list with vcf individuals in correct order Returns: ind_pos(dict): Map from ind_id -> index position """ ind_pos = {} if individuals: for i, ind in enu...
python
def get_individual_positions(individuals): """Return a dictionary with individual positions Args: individuals(list): A list with vcf individuals in correct order Returns: ind_pos(dict): Map from ind_id -> index position """ ind_pos = {} if individuals: for i, ind in enu...
[ "def", "get_individual_positions", "(", "individuals", ")", ":", "ind_pos", "=", "{", "}", "if", "individuals", ":", "for", "i", ",", "ind", "in", "enumerate", "(", "individuals", ")", ":", "ind_pos", "[", "ind", "]", "=", "i", "return", "ind_pos" ]
Return a dictionary with individual positions Args: individuals(list): A list with vcf individuals in correct order Returns: ind_pos(dict): Map from ind_id -> index position
[ "Return", "a", "dictionary", "with", "individual", "positions" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/build_models/case.py#L8-L21
moonso/loqusdb
loqusdb/build_models/case.py
build_case
def build_case(case, vcf_individuals=None, case_id=None, vcf_path=None, sv_individuals=None, vcf_sv_path=None, nr_variants=None, nr_sv_variants=None, profiles=None, matches=None, profile_path=None): """Build a Case from the given information Args: case(ped_parser.Family): ...
python
def build_case(case, vcf_individuals=None, case_id=None, vcf_path=None, sv_individuals=None, vcf_sv_path=None, nr_variants=None, nr_sv_variants=None, profiles=None, matches=None, profile_path=None): """Build a Case from the given information Args: case(ped_parser.Family): ...
[ "def", "build_case", "(", "case", ",", "vcf_individuals", "=", "None", ",", "case_id", "=", "None", ",", "vcf_path", "=", "None", ",", "sv_individuals", "=", "None", ",", "vcf_sv_path", "=", "None", ",", "nr_variants", "=", "None", ",", "nr_sv_variants", "...
Build a Case from the given information Args: case(ped_parser.Family): A family object vcf_individuals(list): Show the order of inds in vcf file case_id(str): If another name than the one in family file should be used vcf_path(str) sv_individuals(list): Show the order of ind...
[ "Build", "a", "Case", "from", "the", "given", "information" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/build_models/case.py#L23-L122
yjzhang/uncurl_python
uncurl/simulation.py
generate_poisson_data
def generate_poisson_data(centers, n_cells, cluster_probs=None): """ Generates poisson-distributed data, given a set of means for each cluster. Args: centers (array): genes x clusters matrix n_cells (int): number of output cells cluster_probs (array): prior probability for each clus...
python
def generate_poisson_data(centers, n_cells, cluster_probs=None): """ Generates poisson-distributed data, given a set of means for each cluster. Args: centers (array): genes x clusters matrix n_cells (int): number of output cells cluster_probs (array): prior probability for each clus...
[ "def", "generate_poisson_data", "(", "centers", ",", "n_cells", ",", "cluster_probs", "=", "None", ")", ":", "genes", ",", "clusters", "=", "centers", ".", "shape", "output", "=", "np", ".", "zeros", "(", "(", "genes", ",", "n_cells", ")", ")", "if", "...
Generates poisson-distributed data, given a set of means for each cluster. Args: centers (array): genes x clusters matrix n_cells (int): number of output cells cluster_probs (array): prior probability for each cluster. Default: uniform. Returns: output - array with ...
[ "Generates", "poisson", "-", "distributed", "data", "given", "a", "set", "of", "means", "for", "each", "cluster", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/simulation.py#L5-L28
yjzhang/uncurl_python
uncurl/simulation.py
generate_zip_data
def generate_zip_data(M, L, n_cells, cluster_probs=None): """ Generates zero-inflated poisson-distributed data, given a set of means and zero probs for each cluster. Args: M (array): genes x clusters matrix L (array): genes x clusters matrix - zero-inflation parameters n_cells (int)...
python
def generate_zip_data(M, L, n_cells, cluster_probs=None): """ Generates zero-inflated poisson-distributed data, given a set of means and zero probs for each cluster. Args: M (array): genes x clusters matrix L (array): genes x clusters matrix - zero-inflation parameters n_cells (int)...
[ "def", "generate_zip_data", "(", "M", ",", "L", ",", "n_cells", ",", "cluster_probs", "=", "None", ")", ":", "genes", ",", "clusters", "=", "M", ".", "shape", "output", "=", "np", ".", "zeros", "(", "(", "genes", ",", "n_cells", ")", ")", "if", "cl...
Generates zero-inflated poisson-distributed data, given a set of means and zero probs for each cluster. Args: M (array): genes x clusters matrix L (array): genes x clusters matrix - zero-inflation parameters n_cells (int): number of output cells cluster_probs (array): prior probabil...
[ "Generates", "zero", "-", "inflated", "poisson", "-", "distributed", "data", "given", "a", "set", "of", "means", "and", "zero", "probs", "for", "each", "cluster", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/simulation.py#L30-L55
yjzhang/uncurl_python
uncurl/simulation.py
generate_state_data
def generate_state_data(means, weights): """ Generates data according to the Poisson Convex Mixture Model. Args: means (array): Cell types- genes x clusters weights (array): Cell cluster assignments- clusters x cells Returns: data matrix - genes x cells """ x_true = np....
python
def generate_state_data(means, weights): """ Generates data according to the Poisson Convex Mixture Model. Args: means (array): Cell types- genes x clusters weights (array): Cell cluster assignments- clusters x cells Returns: data matrix - genes x cells """ x_true = np....
[ "def", "generate_state_data", "(", "means", ",", "weights", ")", ":", "x_true", "=", "np", ".", "dot", "(", "means", ",", "weights", ")", "sample", "=", "np", ".", "random", ".", "poisson", "(", "x_true", ")", "return", "sample", ".", "astype", "(", ...
Generates data according to the Poisson Convex Mixture Model. Args: means (array): Cell types- genes x clusters weights (array): Cell cluster assignments- clusters x cells Returns: data matrix - genes x cells
[ "Generates", "data", "according", "to", "the", "Poisson", "Convex", "Mixture", "Model", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/simulation.py#L58-L71
yjzhang/uncurl_python
uncurl/simulation.py
generate_zip_state_data
def generate_zip_state_data(means, weights, z): """ Generates data according to the Zero-inflated Poisson Convex Mixture Model. Args: means (array): Cell types- genes x clusters weights (array): Cell cluster assignments- clusters x cells z (float): zero-inflation parameter Retu...
python
def generate_zip_state_data(means, weights, z): """ Generates data according to the Zero-inflated Poisson Convex Mixture Model. Args: means (array): Cell types- genes x clusters weights (array): Cell cluster assignments- clusters x cells z (float): zero-inflation parameter Retu...
[ "def", "generate_zip_state_data", "(", "means", ",", "weights", ",", "z", ")", ":", "x_true", "=", "np", ".", "dot", "(", "means", ",", "weights", ")", "sample", "=", "np", ".", "random", ".", "poisson", "(", "x_true", ")", "random", "=", "np", ".", ...
Generates data according to the Zero-inflated Poisson Convex Mixture Model. Args: means (array): Cell types- genes x clusters weights (array): Cell cluster assignments- clusters x cells z (float): zero-inflation parameter Returns: data matrix - genes x cells
[ "Generates", "data", "according", "to", "the", "Zero", "-", "inflated", "Poisson", "Convex", "Mixture", "Model", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/simulation.py#L73-L89
yjzhang/uncurl_python
uncurl/simulation.py
generate_nb_state_data
def generate_nb_state_data(means, weights, R): """ Generates data according to the Negative Binomial Convex Mixture Model. Args: means (array): Cell types- genes x clusters weights (array): Cell cluster assignments- clusters x cells R (array): dispersion parameter - 1 x genes R...
python
def generate_nb_state_data(means, weights, R): """ Generates data according to the Negative Binomial Convex Mixture Model. Args: means (array): Cell types- genes x clusters weights (array): Cell cluster assignments- clusters x cells R (array): dispersion parameter - 1 x genes R...
[ "def", "generate_nb_state_data", "(", "means", ",", "weights", ",", "R", ")", ":", "cells", "=", "weights", ".", "shape", "[", "1", "]", "# x_true = true means", "x_true", "=", "np", ".", "dot", "(", "means", ",", "weights", ")", "# convert means into P", ...
Generates data according to the Negative Binomial Convex Mixture Model. Args: means (array): Cell types- genes x clusters weights (array): Cell cluster assignments- clusters x cells R (array): dispersion parameter - 1 x genes Returns: data matrix - genes x cells
[ "Generates", "data", "according", "to", "the", "Negative", "Binomial", "Convex", "Mixture", "Model", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/simulation.py#L91-L110
yjzhang/uncurl_python
uncurl/simulation.py
generate_nb_states
def generate_nb_states(n_states, n_cells, n_genes): """ Generates means and weights for the Negative Binomial Mixture Model. Weights are distributed Dirichlet(1,1,...), means are rand(0, 1). Returned values can be passed to generate_state_data(M, W). Args: n_states (int): number of states o...
python
def generate_nb_states(n_states, n_cells, n_genes): """ Generates means and weights for the Negative Binomial Mixture Model. Weights are distributed Dirichlet(1,1,...), means are rand(0, 1). Returned values can be passed to generate_state_data(M, W). Args: n_states (int): number of states o...
[ "def", "generate_nb_states", "(", "n_states", ",", "n_cells", ",", "n_genes", ")", ":", "W", "=", "np", ".", "random", ".", "dirichlet", "(", "[", "1", "]", "*", "n_states", ",", "size", "=", "(", "n_cells", ",", ")", ")", "W", "=", "W", ".", "T"...
Generates means and weights for the Negative Binomial Mixture Model. Weights are distributed Dirichlet(1,1,...), means are rand(0, 1). Returned values can be passed to generate_state_data(M, W). Args: n_states (int): number of states or clusters n_cells (int): number of cells n_gene...
[ "Generates", "means", "and", "weights", "for", "the", "Negative", "Binomial", "Mixture", "Model", ".", "Weights", "are", "distributed", "Dirichlet", "(", "1", "1", "...", ")", "means", "are", "rand", "(", "0", "1", ")", ".", "Returned", "values", "can", ...
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/simulation.py#L112-L132
yjzhang/uncurl_python
uncurl/simulation.py
generate_poisson_states
def generate_poisson_states(n_states, n_cells, n_genes): """ Generates means and weights for the Poisson Convex Mixture Model. Weights are distributed Dirichlet(1,1,...), means are rand(0, 100). Returned values can be passed to generate_state_data(M, W). Args: n_states (int): number of stat...
python
def generate_poisson_states(n_states, n_cells, n_genes): """ Generates means and weights for the Poisson Convex Mixture Model. Weights are distributed Dirichlet(1,1,...), means are rand(0, 100). Returned values can be passed to generate_state_data(M, W). Args: n_states (int): number of stat...
[ "def", "generate_poisson_states", "(", "n_states", ",", "n_cells", ",", "n_genes", ")", ":", "W", "=", "np", ".", "random", ".", "dirichlet", "(", "[", "1", "]", "*", "n_states", ",", "size", "=", "(", "n_cells", ",", ")", ")", "W", "=", "W", ".", ...
Generates means and weights for the Poisson Convex Mixture Model. Weights are distributed Dirichlet(1,1,...), means are rand(0, 100). Returned values can be passed to generate_state_data(M, W). Args: n_states (int): number of states or clusters n_cells (int): number of cells n_genes...
[ "Generates", "means", "and", "weights", "for", "the", "Poisson", "Convex", "Mixture", "Model", ".", "Weights", "are", "distributed", "Dirichlet", "(", "1", "1", "...", ")", "means", "are", "rand", "(", "0", "100", ")", ".", "Returned", "values", "can", "...
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/simulation.py#L134-L152
yjzhang/uncurl_python
uncurl/simulation.py
generate_poisson_lineage
def generate_poisson_lineage(n_states, n_cells_per_cluster, n_genes, means=300): """ Generates a lineage for each state- assumes that each state has a common ancestor. Returns: M - genes x clusters W - clusters x cells """ # means... M = np.random.random((n_genes, n_states))...
python
def generate_poisson_lineage(n_states, n_cells_per_cluster, n_genes, means=300): """ Generates a lineage for each state- assumes that each state has a common ancestor. Returns: M - genes x clusters W - clusters x cells """ # means... M = np.random.random((n_genes, n_states))...
[ "def", "generate_poisson_lineage", "(", "n_states", ",", "n_cells_per_cluster", ",", "n_genes", ",", "means", "=", "300", ")", ":", "# means...", "M", "=", "np", ".", "random", ".", "random", "(", "(", "n_genes", ",", "n_states", ")", ")", "*", "means", ...
Generates a lineage for each state- assumes that each state has a common ancestor. Returns: M - genes x clusters W - clusters x cells
[ "Generates", "a", "lineage", "for", "each", "state", "-", "assumes", "that", "each", "state", "has", "a", "common", "ancestor", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/simulation.py#L154-L180
yjzhang/uncurl_python
uncurl/simulation.py
generate_nb_data
def generate_nb_data(P, R, n_cells, assignments=None): """ Generates negative binomial data Args: P (array): genes x clusters R (array): genes x clusters n_cells (int): number of cells assignments (list): cluster assignment of each cell. Default: random uniform ...
python
def generate_nb_data(P, R, n_cells, assignments=None): """ Generates negative binomial data Args: P (array): genes x clusters R (array): genes x clusters n_cells (int): number of cells assignments (list): cluster assignment of each cell. Default: random uniform ...
[ "def", "generate_nb_data", "(", "P", ",", "R", ",", "n_cells", ",", "assignments", "=", "None", ")", ":", "genes", ",", "clusters", "=", "P", ".", "shape", "output", "=", "np", ".", "zeros", "(", "(", "genes", ",", "n_cells", ")", ")", "if", "assig...
Generates negative binomial data Args: P (array): genes x clusters R (array): genes x clusters n_cells (int): number of cells assignments (list): cluster assignment of each cell. Default: random uniform Returns: data array with shape genes x cells la...
[ "Generates", "negative", "binomial", "data" ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/simulation.py#L182-L210
yjzhang/uncurl_python
uncurl/vis.py
visualize_poisson_w
def visualize_poisson_w(w, labels, filename, method='pca', figsize=(18,10), title='', **scatter_options): """ Saves a scatter plot of a visualization of W, the result from Poisson SE. """ if method == 'pca': pca = PCA(2) r_dim_red = pca.fit_transform(w.T).T elif method == 'tsne': ...
python
def visualize_poisson_w(w, labels, filename, method='pca', figsize=(18,10), title='', **scatter_options): """ Saves a scatter plot of a visualization of W, the result from Poisson SE. """ if method == 'pca': pca = PCA(2) r_dim_red = pca.fit_transform(w.T).T elif method == 'tsne': ...
[ "def", "visualize_poisson_w", "(", "w", ",", "labels", ",", "filename", ",", "method", "=", "'pca'", ",", "figsize", "=", "(", "18", ",", "10", ")", ",", "title", "=", "''", ",", "*", "*", "scatter_options", ")", ":", "if", "method", "==", "'pca'", ...
Saves a scatter plot of a visualization of W, the result from Poisson SE.
[ "Saves", "a", "scatter", "plot", "of", "a", "visualization", "of", "W", "the", "result", "from", "Poisson", "SE", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/vis.py#L6-L18
yjzhang/uncurl_python
uncurl/vis.py
visualize_dim_red
def visualize_dim_red(r, labels, filename=None, figsize=(18,10), title='', legend=True, label_map=None, label_scale=False, label_color_map=None, **scatter_options): """ Saves a scatter plot of a (2,n) matrix r, where each column is a cell. Args: r (array): (2,n) matrix labels (array): (n,) ...
python
def visualize_dim_red(r, labels, filename=None, figsize=(18,10), title='', legend=True, label_map=None, label_scale=False, label_color_map=None, **scatter_options): """ Saves a scatter plot of a (2,n) matrix r, where each column is a cell. Args: r (array): (2,n) matrix labels (array): (n,) ...
[ "def", "visualize_dim_red", "(", "r", ",", "labels", ",", "filename", "=", "None", ",", "figsize", "=", "(", "18", ",", "10", ")", ",", "title", "=", "''", ",", "legend", "=", "True", ",", "label_map", "=", "None", ",", "label_scale", "=", "False", ...
Saves a scatter plot of a (2,n) matrix r, where each column is a cell. Args: r (array): (2,n) matrix labels (array): (n,) array of ints/strings or floats. Can be None. filename (string): string to save the output graph. If None, then this just displays the plot. figsize (tuple): Def...
[ "Saves", "a", "scatter", "plot", "of", "a", "(", "2", "n", ")", "matrix", "r", "where", "each", "column", "is", "a", "cell", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/vis.py#L20-L58
yjzhang/uncurl_python
uncurl/experiment_runner.py
run_experiment
def run_experiment(methods, data, n_classes, true_labels, n_runs=10, use_purity=True, use_nmi=False, use_ari=False, use_nne=False, consensus=False): """ runs a pre-processing + clustering experiment... exactly one of use_purity, use_nmi, or use_ari can be true Args: methods: list of 2-tuples. ...
python
def run_experiment(methods, data, n_classes, true_labels, n_runs=10, use_purity=True, use_nmi=False, use_ari=False, use_nne=False, consensus=False): """ runs a pre-processing + clustering experiment... exactly one of use_purity, use_nmi, or use_ari can be true Args: methods: list of 2-tuples. ...
[ "def", "run_experiment", "(", "methods", ",", "data", ",", "n_classes", ",", "true_labels", ",", "n_runs", "=", "10", ",", "use_purity", "=", "True", ",", "use_nmi", "=", "False", ",", "use_ari", "=", "False", ",", "use_nne", "=", "False", ",", "consensu...
runs a pre-processing + clustering experiment... exactly one of use_purity, use_nmi, or use_ari can be true Args: methods: list of 2-tuples. The first element is either a single Preprocess object or a list of Preprocess objects, to be applied in sequence to the data. The second element is either a sin...
[ "runs", "a", "pre", "-", "processing", "+", "clustering", "experiment", "..." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/experiment_runner.py#L889-L1056
yjzhang/uncurl_python
uncurl/experiment_runner.py
generate_visualizations
def generate_visualizations(methods, data, true_labels, base_dir = 'visualizations', figsize=(18,10), **scatter_options): """ Generates visualization scatters for all the methods. Args: methods: follows same format as run_experiments. List of tuples. data: genes x cells true...
python
def generate_visualizations(methods, data, true_labels, base_dir = 'visualizations', figsize=(18,10), **scatter_options): """ Generates visualization scatters for all the methods. Args: methods: follows same format as run_experiments. List of tuples. data: genes x cells true...
[ "def", "generate_visualizations", "(", "methods", ",", "data", ",", "true_labels", ",", "base_dir", "=", "'visualizations'", ",", "figsize", "=", "(", "18", ",", "10", ")", ",", "*", "*", "scatter_options", ")", ":", "plt", ".", "figure", "(", "figsize", ...
Generates visualization scatters for all the methods. Args: methods: follows same format as run_experiments. List of tuples. data: genes x cells true_labels: array of integers base_dir: base directory to save all the plots figsize: tuple of ints representing size of figure ...
[ "Generates", "visualization", "scatters", "for", "all", "the", "methods", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/experiment_runner.py#L1058-L1128
yjzhang/uncurl_python
uncurl/experiment_runner.py
PoissonSE.run
def run(self, data): """ Returns: list of W, M*W ll """ if self.normalize_data: data = cell_normalize(data) M, W, ll = poisson_estimate_state(data, **self.params) outputs = [] if self.return_w: outputs.append(W) ...
python
def run(self, data): """ Returns: list of W, M*W ll """ if self.normalize_data: data = cell_normalize(data) M, W, ll = poisson_estimate_state(data, **self.params) outputs = [] if self.return_w: outputs.append(W) ...
[ "def", "run", "(", "self", ",", "data", ")", ":", "if", "self", ".", "normalize_data", ":", "data", "=", "cell_normalize", "(", "data", ")", "M", ",", "W", ",", "ll", "=", "poisson_estimate_state", "(", "data", ",", "*", "*", "self", ".", "params", ...
Returns: list of W, M*W ll
[ "Returns", ":", "list", "of", "W", "M", "*", "W", "ll" ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/experiment_runner.py#L231-L250
markperdue/pyvesync
src/pyvesync/helpers.py
Helpers.calculate_hex
def calculate_hex(hex_string): """Credit for conversion to itsnotlupus/vesync_wsproxy""" hex_conv = hex_string.split(':') converted_hex = (int(hex_conv[0], 16) + int(hex_conv[1], 16))/8192 return converted_hex
python
def calculate_hex(hex_string): """Credit for conversion to itsnotlupus/vesync_wsproxy""" hex_conv = hex_string.split(':') converted_hex = (int(hex_conv[0], 16) + int(hex_conv[1], 16))/8192 return converted_hex
[ "def", "calculate_hex", "(", "hex_string", ")", ":", "hex_conv", "=", "hex_string", ".", "split", "(", "':'", ")", "converted_hex", "=", "(", "int", "(", "hex_conv", "[", "0", "]", ",", "16", ")", "+", "int", "(", "hex_conv", "[", "1", "]", ",", "1...
Credit for conversion to itsnotlupus/vesync_wsproxy
[ "Credit", "for", "conversion", "to", "itsnotlupus", "/", "vesync_wsproxy" ]
train
https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/src/pyvesync/helpers.py#L122-L127
markperdue/pyvesync
src/pyvesync/helpers.py
Helpers.resolve_updates
def resolve_updates(orig_list, updated_list): """Merges changes from one list of devices against another""" if updated_list is not None and updated_list: if orig_list is None: orig_list = updated_list else: # Add new devices not in list but found ...
python
def resolve_updates(orig_list, updated_list): """Merges changes from one list of devices against another""" if updated_list is not None and updated_list: if orig_list is None: orig_list = updated_list else: # Add new devices not in list but found ...
[ "def", "resolve_updates", "(", "orig_list", ",", "updated_list", ")", ":", "if", "updated_list", "is", "not", "None", "and", "updated_list", ":", "if", "orig_list", "is", "None", ":", "orig_list", "=", "updated_list", "else", ":", "# Add new devices not in list bu...
Merges changes from one list of devices against another
[ "Merges", "changes", "from", "one", "list", "of", "devices", "against", "another" ]
train
https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/src/pyvesync/helpers.py#L222-L256
fbergmann/libSEDML
examples/python/create_sedml.py
main
def main (args): """Usage: create_sedml output-filename """ if (len(args) != 2): print(main.__doc__) sys.exit(1); # create the document doc = libsedml.SedDocument(); doc.setLevel(1); doc.setVersion(1); # create a first model referencing an sbml file model = doc.createModel(); model.setId("...
python
def main (args): """Usage: create_sedml output-filename """ if (len(args) != 2): print(main.__doc__) sys.exit(1); # create the document doc = libsedml.SedDocument(); doc.setLevel(1); doc.setVersion(1); # create a first model referencing an sbml file model = doc.createModel(); model.setId("...
[ "def", "main", "(", "args", ")", ":", "if", "(", "len", "(", "args", ")", "!=", "2", ")", ":", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", "1", ")", "# create the document", "doc", "=", "libsedml", ".", "SedDocument", "(", ...
Usage: create_sedml output-filename
[ "Usage", ":", "create_sedml", "output", "-", "filename" ]
train
https://github.com/fbergmann/libSEDML/blob/2611274d993cb92c663f8f0296896a6e441f75fd/examples/python/create_sedml.py#L41-L163
moonso/loqusdb
loqusdb/utils/profiling.py
get_profiles
def get_profiles(adapter, vcf_file): """Given a vcf, get a profile string for each sample in the vcf based on the profile variants in the database Args: adapter(MongoAdapter): Adapter to mongodb vcf_file(str): Path to vcf file Returns: profiles (dict(str)): The profiles (given...
python
def get_profiles(adapter, vcf_file): """Given a vcf, get a profile string for each sample in the vcf based on the profile variants in the database Args: adapter(MongoAdapter): Adapter to mongodb vcf_file(str): Path to vcf file Returns: profiles (dict(str)): The profiles (given...
[ "def", "get_profiles", "(", "adapter", ",", "vcf_file", ")", ":", "vcf", "=", "get_file_handle", "(", "vcf_file", ")", "individuals", "=", "vcf", ".", "samples", "profiles", "=", "{", "individual", ":", "[", "]", "for", "individual", "in", "individuals", "...
Given a vcf, get a profile string for each sample in the vcf based on the profile variants in the database Args: adapter(MongoAdapter): Adapter to mongodb vcf_file(str): Path to vcf file Returns: profiles (dict(str)): The profiles (given as strings) for each sample ...
[ "Given", "a", "vcf", "get", "a", "profile", "string", "for", "each", "sample", "in", "the", "vcf", "based", "on", "the", "profile", "variants", "in", "the", "database" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/profiling.py#L15-L76
moonso/loqusdb
loqusdb/utils/profiling.py
profile_match
def profile_match(adapter, profiles, hard_threshold=0.95, soft_threshold=0.9): """ given a dict of profiles, searches through all the samples in the DB for a match. If a matching sample is found an exception is raised, and the variants will not be loaded into the database. Args: ...
python
def profile_match(adapter, profiles, hard_threshold=0.95, soft_threshold=0.9): """ given a dict of profiles, searches through all the samples in the DB for a match. If a matching sample is found an exception is raised, and the variants will not be loaded into the database. Args: ...
[ "def", "profile_match", "(", "adapter", ",", "profiles", ",", "hard_threshold", "=", "0.95", ",", "soft_threshold", "=", "0.9", ")", ":", "matches", "=", "{", "sample", ":", "[", "]", "for", "sample", "in", "profiles", ".", "keys", "(", ")", "}", "for"...
given a dict of profiles, searches through all the samples in the DB for a match. If a matching sample is found an exception is raised, and the variants will not be loaded into the database. Args: adapter (MongoAdapter): Adapter to mongodb profiles (dict(str)): The profi...
[ "given", "a", "dict", "of", "profiles", "searches", "through", "all", "the", "samples", "in", "the", "DB", "for", "a", "match", ".", "If", "a", "matching", "sample", "is", "found", "an", "exception", "is", "raised", "and", "the", "variants", "will", "not...
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/profiling.py#L78-L124
moonso/loqusdb
loqusdb/utils/profiling.py
compare_profiles
def compare_profiles(profile1, profile2): """ Given two profiles, determine the ratio of similarity, i.e. the hamming distance between the strings. Args: profile1/2 (str): profile string Returns: similarity_ratio (float): the ratio of similiarity (0-1) "...
python
def compare_profiles(profile1, profile2): """ Given two profiles, determine the ratio of similarity, i.e. the hamming distance between the strings. Args: profile1/2 (str): profile string Returns: similarity_ratio (float): the ratio of similiarity (0-1) "...
[ "def", "compare_profiles", "(", "profile1", ",", "profile2", ")", ":", "length", "=", "len", "(", "profile1", ")", "profile1", "=", "np", ".", "array", "(", "list", "(", "profile1", ")", ")", "profile2", "=", "np", ".", "array", "(", "list", "(", "pr...
Given two profiles, determine the ratio of similarity, i.e. the hamming distance between the strings. Args: profile1/2 (str): profile string Returns: similarity_ratio (float): the ratio of similiarity (0-1)
[ "Given", "two", "profiles", "determine", "the", "ratio", "of", "similarity", "i", ".", "e", ".", "the", "hamming", "distance", "between", "the", "strings", "." ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/profiling.py#L128-L151
moonso/loqusdb
loqusdb/utils/profiling.py
update_profiles
def update_profiles(adapter): """ For all cases having vcf_path, update the profile string for the samples Args: adapter (MongoAdapter): Adapter to mongodb """ for case in adapter.cases(): #If the case has a vcf_path, get the profiles and update the #case with new profil...
python
def update_profiles(adapter): """ For all cases having vcf_path, update the profile string for the samples Args: adapter (MongoAdapter): Adapter to mongodb """ for case in adapter.cases(): #If the case has a vcf_path, get the profiles and update the #case with new profil...
[ "def", "update_profiles", "(", "adapter", ")", ":", "for", "case", "in", "adapter", ".", "cases", "(", ")", ":", "#If the case has a vcf_path, get the profiles and update the", "#case with new profiled individuals.", "if", "case", ".", "get", "(", "'profile_path'", ")",...
For all cases having vcf_path, update the profile string for the samples Args: adapter (MongoAdapter): Adapter to mongodb
[ "For", "all", "cases", "having", "vcf_path", "update", "the", "profile", "string", "for", "the", "samples" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/profiling.py#L154-L186
moonso/loqusdb
loqusdb/utils/profiling.py
profile_stats
def profile_stats(adapter, threshold = 0.9): """ Compares the pairwise hamming distances for all the sample profiles in the database. Returns a table of the number of distances within given ranges. Args: adapter (MongoAdapter): Adapter to mongodb threshold (...
python
def profile_stats(adapter, threshold = 0.9): """ Compares the pairwise hamming distances for all the sample profiles in the database. Returns a table of the number of distances within given ranges. Args: adapter (MongoAdapter): Adapter to mongodb threshold (...
[ "def", "profile_stats", "(", "adapter", ",", "threshold", "=", "0.9", ")", ":", "profiles", "=", "[", "]", "samples", "=", "[", "]", "#Instatiate the distance dictionary with a count 0 for all the ranges", "distance_dict", "=", "{", "key", ":", "0", "for", "key", ...
Compares the pairwise hamming distances for all the sample profiles in the database. Returns a table of the number of distances within given ranges. Args: adapter (MongoAdapter): Adapter to mongodb threshold (float): If any distance is found above this threshold ...
[ "Compares", "the", "pairwise", "hamming", "distances", "for", "all", "the", "sample", "profiles", "in", "the", "database", ".", "Returns", "a", "table", "of", "the", "number", "of", "distances", "within", "given", "ranges", "." ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/profiling.py#L189-L248
yjzhang/uncurl_python
uncurl/evaluation.py
purity
def purity(labels, true_labels): """ Calculates the purity score for the given labels. Args: labels (array): 1D array of integers true_labels (array): 1D array of integers - true labels Returns: purity score - a float bewteen 0 and 1. Closer to 1 is better. """ purity =...
python
def purity(labels, true_labels): """ Calculates the purity score for the given labels. Args: labels (array): 1D array of integers true_labels (array): 1D array of integers - true labels Returns: purity score - a float bewteen 0 and 1. Closer to 1 is better. """ purity =...
[ "def", "purity", "(", "labels", ",", "true_labels", ")", ":", "purity", "=", "0.0", "for", "i", "in", "set", "(", "labels", ")", ":", "indices", "=", "(", "labels", "==", "i", ")", "true_clusters", "=", "true_labels", "[", "indices", "]", "if", "len"...
Calculates the purity score for the given labels. Args: labels (array): 1D array of integers true_labels (array): 1D array of integers - true labels Returns: purity score - a float bewteen 0 and 1. Closer to 1 is better.
[ "Calculates", "the", "purity", "score", "for", "the", "given", "labels", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/evaluation.py#L6-L26
yjzhang/uncurl_python
uncurl/evaluation.py
nne
def nne(dim_red, true_labels): """ Calculates the nearest neighbor accuracy (basically leave-one-out cross validation with a 1NN classifier). Args: dim_red (array): dimensions (k, cells) true_labels (array): 1d array of integers Returns: Nearest neighbor accuracy - fraction...
python
def nne(dim_red, true_labels): """ Calculates the nearest neighbor accuracy (basically leave-one-out cross validation with a 1NN classifier). Args: dim_red (array): dimensions (k, cells) true_labels (array): 1d array of integers Returns: Nearest neighbor accuracy - fraction...
[ "def", "nne", "(", "dim_red", ",", "true_labels", ")", ":", "# use sklearn's BallTree", "bt", "=", "BallTree", "(", "dim_red", ".", "T", ")", "correct", "=", "0", "for", "i", ",", "l", "in", "enumerate", "(", "true_labels", ")", ":", "dist", ",", "ind"...
Calculates the nearest neighbor accuracy (basically leave-one-out cross validation with a 1NN classifier). Args: dim_red (array): dimensions (k, cells) true_labels (array): 1d array of integers Returns: Nearest neighbor accuracy - fraction of points for which the 1NN 1NN cl...
[ "Calculates", "the", "nearest", "neighbor", "accuracy", "(", "basically", "leave", "-", "one", "-", "out", "cross", "validation", "with", "a", "1NN", "classifier", ")", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/evaluation.py#L28-L49
yjzhang/uncurl_python
uncurl/evaluation.py
mdl
def mdl(ll, k, data): """ Returns the minimum description length score of the model given its log-likelihood and k, the number of cell types. a lower cost is better... """ """ N - no. of genes n - no. of cells k - no. of cell types R - sum(Dataset) i.e. total no. of reads ...
python
def mdl(ll, k, data): """ Returns the minimum description length score of the model given its log-likelihood and k, the number of cell types. a lower cost is better... """ """ N - no. of genes n - no. of cells k - no. of cell types R - sum(Dataset) i.e. total no. of reads ...
[ "def", "mdl", "(", "ll", ",", "k", ",", "data", ")", ":", "\"\"\"\n N - no. of genes\n n - no. of cells \n k - no. of cell types\n R - sum(Dataset) i.e. total no. of reads\n\n function TotCost = TotBits(N,m,p,R,C)\n # C is the cost from the cost function\n TotCost = ...
Returns the minimum description length score of the model given its log-likelihood and k, the number of cell types. a lower cost is better...
[ "Returns", "the", "minimum", "description", "length", "score", "of", "the", "model", "given", "its", "log", "-", "likelihood", "and", "k", "the", "number", "of", "cell", "types", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/evaluation.py#L51-L71
yjzhang/uncurl_python
uncurl/nb_clustering.py
find_nb_genes
def find_nb_genes(data): """ Finds the indices of all genes in the dataset that have a mean < 0.9 variance. Returns an array of booleans. """ data_means = data.mean(1) data_vars = data.var(1) nb_indices = data_means < 0.9*data_vars return nb_indices
python
def find_nb_genes(data): """ Finds the indices of all genes in the dataset that have a mean < 0.9 variance. Returns an array of booleans. """ data_means = data.mean(1) data_vars = data.var(1) nb_indices = data_means < 0.9*data_vars return nb_indices
[ "def", "find_nb_genes", "(", "data", ")", ":", "data_means", "=", "data", ".", "mean", "(", "1", ")", "data_vars", "=", "data", ".", "var", "(", "1", ")", "nb_indices", "=", "data_means", "<", "0.9", "*", "data_vars", "return", "nb_indices" ]
Finds the indices of all genes in the dataset that have a mean < 0.9 variance. Returns an array of booleans.
[ "Finds", "the", "indices", "of", "all", "genes", "in", "the", "dataset", "that", "have", "a", "mean", "<", "0", ".", "9", "variance", ".", "Returns", "an", "array", "of", "booleans", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nb_clustering.py#L12-L20
yjzhang/uncurl_python
uncurl/nb_clustering.py
log_ncr
def log_ncr(a, b): """ Returns log(nCr(a,b)), given that b<a. Does not assume that a and b are integers (uses log-gamma). """ val = gammaln(a+1) - gammaln(a-b+1) - gammaln(b+1) return val
python
def log_ncr(a, b): """ Returns log(nCr(a,b)), given that b<a. Does not assume that a and b are integers (uses log-gamma). """ val = gammaln(a+1) - gammaln(a-b+1) - gammaln(b+1) return val
[ "def", "log_ncr", "(", "a", ",", "b", ")", ":", "val", "=", "gammaln", "(", "a", "+", "1", ")", "-", "gammaln", "(", "a", "-", "b", "+", "1", ")", "-", "gammaln", "(", "b", "+", "1", ")", "return", "val" ]
Returns log(nCr(a,b)), given that b<a. Does not assume that a and b are integers (uses log-gamma).
[ "Returns", "log", "(", "nCr", "(", "a", "b", "))", "given", "that", "b<a", ".", "Does", "not", "assume", "that", "a", "and", "b", "are", "integers", "(", "uses", "log", "-", "gamma", ")", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nb_clustering.py#L22-L28
yjzhang/uncurl_python
uncurl/nb_clustering.py
nb_ll
def nb_ll(data, P, R): """ Returns the negative binomial log-likelihood of the data. Args: data (array): genes x cells P (array): NB success probability param - genes x clusters R (array): NB stopping param - genes x clusters Returns: cells x clusters array of log-likel...
python
def nb_ll(data, P, R): """ Returns the negative binomial log-likelihood of the data. Args: data (array): genes x cells P (array): NB success probability param - genes x clusters R (array): NB stopping param - genes x clusters Returns: cells x clusters array of log-likel...
[ "def", "nb_ll", "(", "data", ",", "P", ",", "R", ")", ":", "# TODO: include factorial...", "#data = data + eps", "genes", ",", "cells", "=", "data", ".", "shape", "clusters", "=", "P", ".", "shape", "[", "1", "]", "lls", "=", "np", ".", "zeros", "(", ...
Returns the negative binomial log-likelihood of the data. Args: data (array): genes x cells P (array): NB success probability param - genes x clusters R (array): NB stopping param - genes x clusters Returns: cells x clusters array of log-likelihoods
[ "Returns", "the", "negative", "binomial", "log", "-", "likelihood", "of", "the", "data", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nb_clustering.py#L36-L61
yjzhang/uncurl_python
uncurl/nb_clustering.py
zinb_ll
def zinb_ll(data, P, R, Z): """ Returns the zero-inflated negative binomial log-likelihood of the data. """ lls = nb_ll(data, P, R) clusters = P.shape[1] for c in range(clusters): pass return lls
python
def zinb_ll(data, P, R, Z): """ Returns the zero-inflated negative binomial log-likelihood of the data. """ lls = nb_ll(data, P, R) clusters = P.shape[1] for c in range(clusters): pass return lls
[ "def", "zinb_ll", "(", "data", ",", "P", ",", "R", ",", "Z", ")", ":", "lls", "=", "nb_ll", "(", "data", ",", "P", ",", "R", ")", "clusters", "=", "P", ".", "shape", "[", "1", "]", "for", "c", "in", "range", "(", "clusters", ")", ":", "pass...
Returns the zero-inflated negative binomial log-likelihood of the data.
[ "Returns", "the", "zero", "-", "inflated", "negative", "binomial", "log", "-", "likelihood", "of", "the", "data", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nb_clustering.py#L63-L71
yjzhang/uncurl_python
uncurl/nb_clustering.py
nb_ll_row
def nb_ll_row(params, data_row): """ returns the negative LL of a single row. Args: params (array) - [p, r] data_row (array) - 1d array of data Returns: LL of row """ p = params[0] r = params[1] n = len(data_row) ll = np.sum(gammaln(data_row + r)) - np.sum(g...
python
def nb_ll_row(params, data_row): """ returns the negative LL of a single row. Args: params (array) - [p, r] data_row (array) - 1d array of data Returns: LL of row """ p = params[0] r = params[1] n = len(data_row) ll = np.sum(gammaln(data_row + r)) - np.sum(g...
[ "def", "nb_ll_row", "(", "params", ",", "data_row", ")", ":", "p", "=", "params", "[", "0", "]", "r", "=", "params", "[", "1", "]", "n", "=", "len", "(", "data_row", ")", "ll", "=", "np", ".", "sum", "(", "gammaln", "(", "data_row", "+", "r", ...
returns the negative LL of a single row. Args: params (array) - [p, r] data_row (array) - 1d array of data Returns: LL of row
[ "returns", "the", "negative", "LL", "of", "a", "single", "row", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nb_clustering.py#L73-L91
yjzhang/uncurl_python
uncurl/nb_clustering.py
nb_r_deriv
def nb_r_deriv(r, data_row): """ Derivative of log-likelihood wrt r (formula from wikipedia) Args: r (float): the R paramemter in the NB distribution data_row (array): 1d array of length cells """ n = len(data_row) d = sum(digamma(data_row + r)) - n*digamma(r) + n*np.log(r/(r+np...
python
def nb_r_deriv(r, data_row): """ Derivative of log-likelihood wrt r (formula from wikipedia) Args: r (float): the R paramemter in the NB distribution data_row (array): 1d array of length cells """ n = len(data_row) d = sum(digamma(data_row + r)) - n*digamma(r) + n*np.log(r/(r+np...
[ "def", "nb_r_deriv", "(", "r", ",", "data_row", ")", ":", "n", "=", "len", "(", "data_row", ")", "d", "=", "sum", "(", "digamma", "(", "data_row", "+", "r", ")", ")", "-", "n", "*", "digamma", "(", "r", ")", "+", "n", "*", "np", ".", "log", ...
Derivative of log-likelihood wrt r (formula from wikipedia) Args: r (float): the R paramemter in the NB distribution data_row (array): 1d array of length cells
[ "Derivative", "of", "log", "-", "likelihood", "wrt", "r", "(", "formula", "from", "wikipedia", ")" ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nb_clustering.py#L93-L103
yjzhang/uncurl_python
uncurl/nb_clustering.py
nb_fit
def nb_fit(data, P_init=None, R_init=None, epsilon=1e-8, max_iters=100): """ Fits the NB distribution to data using method of moments. Args: data (array): genes x cells P_init (array, optional): NB success prob param - genes x 1 R_init (array, optional): NB stopping param - genes x ...
python
def nb_fit(data, P_init=None, R_init=None, epsilon=1e-8, max_iters=100): """ Fits the NB distribution to data using method of moments. Args: data (array): genes x cells P_init (array, optional): NB success prob param - genes x 1 R_init (array, optional): NB stopping param - genes x ...
[ "def", "nb_fit", "(", "data", ",", "P_init", "=", "None", ",", "R_init", "=", "None", ",", "epsilon", "=", "1e-8", ",", "max_iters", "=", "100", ")", ":", "means", "=", "data", ".", "mean", "(", "1", ")", "variances", "=", "data", ".", "var", "("...
Fits the NB distribution to data using method of moments. Args: data (array): genes x cells P_init (array, optional): NB success prob param - genes x 1 R_init (array, optional): NB stopping param - genes x 1 Returns: P, R - fit to data
[ "Fits", "the", "NB", "distribution", "to", "data", "using", "method", "of", "moments", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nb_clustering.py#L105-L133
yjzhang/uncurl_python
uncurl/nb_clustering.py
nb_cluster
def nb_cluster(data, k, P_init=None, R_init=None, assignments=None, means=None, max_iters=10): """ Performs negative binomial clustering on the given data. If some genes have mean > variance, then these genes are fitted to a Poisson distribution. Args: data (array): genes x cells k (int): n...
python
def nb_cluster(data, k, P_init=None, R_init=None, assignments=None, means=None, max_iters=10): """ Performs negative binomial clustering on the given data. If some genes have mean > variance, then these genes are fitted to a Poisson distribution. Args: data (array): genes x cells k (int): n...
[ "def", "nb_cluster", "(", "data", ",", "k", ",", "P_init", "=", "None", ",", "R_init", "=", "None", ",", "assignments", "=", "None", ",", "means", "=", "None", ",", "max_iters", "=", "10", ")", ":", "genes", ",", "cells", "=", "data", ".", "shape",...
Performs negative binomial clustering on the given data. If some genes have mean > variance, then these genes are fitted to a Poisson distribution. Args: data (array): genes x cells k (int): number of clusters P_init (array): NB success prob param - genes x k. Default: random R_init...
[ "Performs", "negative", "binomial", "clustering", "on", "the", "given", "data", ".", "If", "some", "genes", "have", "mean", ">", "variance", "then", "these", "genes", "are", "fitted", "to", "a", "Poisson", "distribution", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nb_clustering.py#L141-L186
yjzhang/uncurl_python
uncurl/nb_clustering.py
fit_cluster
def fit_cluster(data, assignments, k, P_init, R_init, means): """ Fits NB/poisson params to a cluster. """ for c in range(k): if data[:,assignments==c].shape[1] == 0: _, assignments = kmeans_pp(data, k) genes, cells = data.shape nb_gene_indices = np.array([True for i in range...
python
def fit_cluster(data, assignments, k, P_init, R_init, means): """ Fits NB/poisson params to a cluster. """ for c in range(k): if data[:,assignments==c].shape[1] == 0: _, assignments = kmeans_pp(data, k) genes, cells = data.shape nb_gene_indices = np.array([True for i in range...
[ "def", "fit_cluster", "(", "data", ",", "assignments", ",", "k", ",", "P_init", ",", "R_init", ",", "means", ")", ":", "for", "c", "in", "range", "(", "k", ")", ":", "if", "data", "[", ":", ",", "assignments", "==", "c", "]", ".", "shape", "[", ...
Fits NB/poisson params to a cluster.
[ "Fits", "NB", "/", "poisson", "params", "to", "a", "cluster", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/nb_clustering.py#L188-L206
yjzhang/uncurl_python
uncurl/zip_utils.py
zip_ll
def zip_ll(data, means, M): """ Calculates the zero-inflated Poisson log-likelihood. Args: data (array): genes x cells means (array): genes x k M (array): genes x k - this is the zero-inflation parameter. Returns: cells x k array of log-likelihood for each cell/cluster ...
python
def zip_ll(data, means, M): """ Calculates the zero-inflated Poisson log-likelihood. Args: data (array): genes x cells means (array): genes x k M (array): genes x k - this is the zero-inflation parameter. Returns: cells x k array of log-likelihood for each cell/cluster ...
[ "def", "zip_ll", "(", "data", ",", "means", ",", "M", ")", ":", "genes", ",", "cells", "=", "data", ".", "shape", "clusters", "=", "means", ".", "shape", "[", "1", "]", "ll", "=", "np", ".", "zeros", "(", "(", "cells", ",", "clusters", ")", ")"...
Calculates the zero-inflated Poisson log-likelihood. Args: data (array): genes x cells means (array): genes x k M (array): genes x k - this is the zero-inflation parameter. Returns: cells x k array of log-likelihood for each cell/cluster pair.
[ "Calculates", "the", "zero", "-", "inflated", "Poisson", "log", "-", "likelihood", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/zip_utils.py#L9-L38
yjzhang/uncurl_python
uncurl/zip_utils.py
zip_ll_row
def zip_ll_row(params, data_row): """ Returns the negative log-likelihood of a row given ZIP data. Args: params (list): [lambda zero-inf] data_row (array): 1d array Returns: negative log-likelihood """ l = params[0] pi = params[1] d0 = (data_row==0) likeliho...
python
def zip_ll_row(params, data_row): """ Returns the negative log-likelihood of a row given ZIP data. Args: params (list): [lambda zero-inf] data_row (array): 1d array Returns: negative log-likelihood """ l = params[0] pi = params[1] d0 = (data_row==0) likeliho...
[ "def", "zip_ll_row", "(", "params", ",", "data_row", ")", ":", "l", "=", "params", "[", "0", "]", "pi", "=", "params", "[", "1", "]", "d0", "=", "(", "data_row", "==", "0", ")", "likelihood", "=", "d0", "*", "pi", "+", "(", "1", "-", "pi", ")...
Returns the negative log-likelihood of a row given ZIP data. Args: params (list): [lambda zero-inf] data_row (array): 1d array Returns: negative log-likelihood
[ "Returns", "the", "negative", "log", "-", "likelihood", "of", "a", "row", "given", "ZIP", "data", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/zip_utils.py#L40-L55
moonso/loqusdb
loqusdb/utils/migrate.py
migrate_database
def migrate_database(adapter): """Migrate an old loqusdb instance to 1.0 Args: adapter Returns: nr_updated(int): Number of variants that where updated """ all_variants = adapter.get_variants() nr_variants = all_variants.count() nr_updated = 0 with progressb...
python
def migrate_database(adapter): """Migrate an old loqusdb instance to 1.0 Args: adapter Returns: nr_updated(int): Number of variants that where updated """ all_variants = adapter.get_variants() nr_variants = all_variants.count() nr_updated = 0 with progressb...
[ "def", "migrate_database", "(", "adapter", ")", ":", "all_variants", "=", "adapter", ".", "get_variants", "(", ")", "nr_variants", "=", "all_variants", ".", "count", "(", ")", "nr_updated", "=", "0", "with", "progressbar", "(", "all_variants", ",", "label", ...
Migrate an old loqusdb instance to 1.0 Args: adapter Returns: nr_updated(int): Number of variants that where updated
[ "Migrate", "an", "old", "loqusdb", "instance", "to", "1", ".", "0", "Args", ":", "adapter", "Returns", ":", "nr_updated", "(", "int", ")", ":", "Number", "of", "variants", "that", "where", "updated" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/migrate.py#L7-L47
fbergmann/libSEDML
examples/python/create_sedml2.py
main
def main (args): """Usage: create_sedml2 output-filename """ if (len(args) != 2): print(main.__doc__) sys.exit(1); # create the document doc = libsedml.SedDocument(); doc.setLevel(1); doc.setVersion(3); # create a data description ddesc = doc.createDataDescription() ddesc.setId('data1')...
python
def main (args): """Usage: create_sedml2 output-filename """ if (len(args) != 2): print(main.__doc__) sys.exit(1); # create the document doc = libsedml.SedDocument(); doc.setLevel(1); doc.setVersion(3); # create a data description ddesc = doc.createDataDescription() ddesc.setId('data1')...
[ "def", "main", "(", "args", ")", ":", "if", "(", "len", "(", "args", ")", "!=", "2", ")", ":", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", "1", ")", "# create the document", "doc", "=", "libsedml", ".", "SedDocument", "(", ...
Usage: create_sedml2 output-filename
[ "Usage", ":", "create_sedml2", "output", "-", "filename" ]
train
https://github.com/fbergmann/libSEDML/blob/2611274d993cb92c663f8f0296896a6e441f75fd/examples/python/create_sedml2.py#L41-L88
yjzhang/uncurl_python
uncurl/gap_score.py
preproc_data
def preproc_data(data, gene_subset=False, **kwargs): """ basic data preprocessing before running gap score Assumes that data is a matrix of shape (genes, cells). Returns a matrix of shape (cells, 8), using the first 8 SVD components. Why 8? It's an arbitrary selection... """ import uncurl ...
python
def preproc_data(data, gene_subset=False, **kwargs): """ basic data preprocessing before running gap score Assumes that data is a matrix of shape (genes, cells). Returns a matrix of shape (cells, 8), using the first 8 SVD components. Why 8? It's an arbitrary selection... """ import uncurl ...
[ "def", "preproc_data", "(", "data", ",", "gene_subset", "=", "False", ",", "*", "*", "kwargs", ")", ":", "import", "uncurl", "from", "uncurl", ".", "preprocessing", "import", "log1p", ",", "cell_normalize", "from", "sklearn", ".", "decomposition", "import", ...
basic data preprocessing before running gap score Assumes that data is a matrix of shape (genes, cells). Returns a matrix of shape (cells, 8), using the first 8 SVD components. Why 8? It's an arbitrary selection...
[ "basic", "data", "preprocessing", "before", "running", "gap", "score" ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/gap_score.py#L7-L25
yjzhang/uncurl_python
uncurl/gap_score.py
calculate_bounding_box
def calculate_bounding_box(data): """ Returns a 2 x m array indicating the min and max along each dimension. """ mins = data.min(0) maxes = data.max(0) return mins, maxes
python
def calculate_bounding_box(data): """ Returns a 2 x m array indicating the min and max along each dimension. """ mins = data.min(0) maxes = data.max(0) return mins, maxes
[ "def", "calculate_bounding_box", "(", "data", ")", ":", "mins", "=", "data", ".", "min", "(", "0", ")", "maxes", "=", "data", ".", "max", "(", "0", ")", "return", "mins", ",", "maxes" ]
Returns a 2 x m array indicating the min and max along each dimension.
[ "Returns", "a", "2", "x", "m", "array", "indicating", "the", "min", "and", "max", "along", "each", "dimension", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/gap_score.py#L27-L34
yjzhang/uncurl_python
uncurl/gap_score.py
calculate_gap
def calculate_gap(data, clustering, km, B=50, **kwargs): """ See: https://datasciencelab.wordpress.com/2013/12/27/finding-the-k-in-k-means-clustering/ https://web.stanford.edu/~hastie/Papers/gap.pdf Returns two results: the gap score, and s_k. """ k = len(set(clustering)) Wk = km.inertia_ ...
python
def calculate_gap(data, clustering, km, B=50, **kwargs): """ See: https://datasciencelab.wordpress.com/2013/12/27/finding-the-k-in-k-means-clustering/ https://web.stanford.edu/~hastie/Papers/gap.pdf Returns two results: the gap score, and s_k. """ k = len(set(clustering)) Wk = km.inertia_ ...
[ "def", "calculate_gap", "(", "data", ",", "clustering", ",", "km", ",", "B", "=", "50", ",", "*", "*", "kwargs", ")", ":", "k", "=", "len", "(", "set", "(", "clustering", ")", ")", "Wk", "=", "km", ".", "inertia_", "mins", ",", "maxes", "=", "c...
See: https://datasciencelab.wordpress.com/2013/12/27/finding-the-k-in-k-means-clustering/ https://web.stanford.edu/~hastie/Papers/gap.pdf Returns two results: the gap score, and s_k.
[ "See", ":", "https", ":", "//", "datasciencelab", ".", "wordpress", ".", "com", "/", "2013", "/", "12", "/", "27", "/", "finding", "-", "the", "-", "k", "-", "in", "-", "k", "-", "means", "-", "clustering", "/" ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/gap_score.py#L36-L58
yjzhang/uncurl_python
uncurl/gap_score.py
run_gap_k_selection
def run_gap_k_selection(data, k_min=1, k_max=50, B=5, skip=5, **kwargs): """ Runs gap score for all k from k_min to k_max. """ if k_min == k_max: return k_min gap_vals = [] sk_vals = [] k_range = list(range(k_min, k_max, skip)) min_k = 0 min_i = 0 for i, k in enum...
python
def run_gap_k_selection(data, k_min=1, k_max=50, B=5, skip=5, **kwargs): """ Runs gap score for all k from k_min to k_max. """ if k_min == k_max: return k_min gap_vals = [] sk_vals = [] k_range = list(range(k_min, k_max, skip)) min_k = 0 min_i = 0 for i, k in enum...
[ "def", "run_gap_k_selection", "(", "data", ",", "k_min", "=", "1", ",", "k_max", "=", "50", ",", "B", "=", "5", ",", "skip", "=", "5", ",", "*", "*", "kwargs", ")", ":", "if", "k_min", "==", "k_max", ":", "return", "k_min", "gap_vals", "=", "[", ...
Runs gap score for all k from k_min to k_max.
[ "Runs", "gap", "score", "for", "all", "k", "from", "k_min", "to", "k_max", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/gap_score.py#L61-L101
bachya/py17track
py17track/client.py
Client._request
async def _request( self, method: str, url: str, *, headers: dict = None, params: dict = None, json: dict = None) -> dict: """Make a request against the RainMachine device.""" if not headers: headers = {} ...
python
async def _request( self, method: str, url: str, *, headers: dict = None, params: dict = None, json: dict = None) -> dict: """Make a request against the RainMachine device.""" if not headers: headers = {} ...
[ "async", "def", "_request", "(", "self", ",", "method", ":", "str", ",", "url", ":", "str", ",", "*", ",", "headers", ":", "dict", "=", "None", ",", "params", ":", "dict", "=", "None", ",", "json", ":", "dict", "=", "None", ")", "->", "dict", "...
Make a request against the RainMachine device.
[ "Make", "a", "request", "against", "the", "RainMachine", "device", "." ]
train
https://github.com/bachya/py17track/blob/e6e64f2a79571433df7ee702cb4ebc4127b7ad6d/py17track/client.py#L22-L43
markperdue/pyvesync
src/pyvesync/vesync.py
VeSync.get_devices
def get_devices(self) -> list: """Return list of VeSync devices""" if not self.enabled: return None self.in_process = True response, _ = helpers.call_api( '/cloud/v1/deviceManaged/devices', 'post', headers=helpers.req_headers(self), ...
python
def get_devices(self) -> list: """Return list of VeSync devices""" if not self.enabled: return None self.in_process = True response, _ = helpers.call_api( '/cloud/v1/deviceManaged/devices', 'post', headers=helpers.req_headers(self), ...
[ "def", "get_devices", "(", "self", ")", "->", "list", ":", "if", "not", "self", ".", "enabled", ":", "return", "None", "self", ".", "in_process", "=", "True", "response", ",", "_", "=", "helpers", ".", "call_api", "(", "'/cloud/v1/deviceManaged/devices'", ...
Return list of VeSync devices
[ "Return", "list", "of", "VeSync", "devices" ]
train
https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/src/pyvesync/vesync.py#L106-L132
markperdue/pyvesync
src/pyvesync/vesync.py
VeSync.login
def login(self) -> bool: """Return True if log in request succeeds""" user_check = isinstance(self.username, str) and len(self.username) > 0 pass_check = isinstance(self.password, str) and len(self.password) > 0 if user_check and pass_check: response, _ = helpers.call_api( ...
python
def login(self) -> bool: """Return True if log in request succeeds""" user_check = isinstance(self.username, str) and len(self.username) > 0 pass_check = isinstance(self.password, str) and len(self.password) > 0 if user_check and pass_check: response, _ = helpers.call_api( ...
[ "def", "login", "(", "self", ")", "->", "bool", ":", "user_check", "=", "isinstance", "(", "self", ".", "username", ",", "str", ")", "and", "len", "(", "self", ".", "username", ")", ">", "0", "pass_check", "=", "isinstance", "(", "self", ".", "passwo...
Return True if log in request succeeds
[ "Return", "True", "if", "log", "in", "request", "succeeds" ]
train
https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/src/pyvesync/vesync.py#L134-L162
markperdue/pyvesync
src/pyvesync/vesync.py
VeSync.update
def update(self): """Fetch updated information about devices""" if self.device_time_check(): if not self.in_process: outlets, switches, fans = self.get_devices() self.outlets = helpers.resolve_updates(self.outlets, outlets) self.switches = h...
python
def update(self): """Fetch updated information about devices""" if self.device_time_check(): if not self.in_process: outlets, switches, fans = self.get_devices() self.outlets = helpers.resolve_updates(self.outlets, outlets) self.switches = h...
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "device_time_check", "(", ")", ":", "if", "not", "self", ".", "in_process", ":", "outlets", ",", "switches", ",", "fans", "=", "self", ".", "get_devices", "(", ")", "self", ".", "outlets", "=...
Fetch updated information about devices
[ "Fetch", "updated", "information", "about", "devices" ]
train
https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/src/pyvesync/vesync.py#L171-L184
markperdue/pyvesync
src/pyvesync/vesync.py
VeSync.update_energy
def update_energy(self, bypass_check=False): """Fetch updated energy information about devices""" for outlet in self.outlets: outlet.update_energy(bypass_check)
python
def update_energy(self, bypass_check=False): """Fetch updated energy information about devices""" for outlet in self.outlets: outlet.update_energy(bypass_check)
[ "def", "update_energy", "(", "self", ",", "bypass_check", "=", "False", ")", ":", "for", "outlet", "in", "self", ".", "outlets", ":", "outlet", ".", "update_energy", "(", "bypass_check", ")" ]
Fetch updated energy information about devices
[ "Fetch", "updated", "energy", "information", "about", "devices" ]
train
https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/src/pyvesync/vesync.py#L186-L189
yjzhang/uncurl_python
uncurl/fit_dist_data.py
DistFitDataset
def DistFitDataset(Dat): """ Given a data matrix, this returns the per-gene fit error for the Poisson, Normal, and Log-Normal distributions. Args: Dat (array): numpy array with shape (genes, cells) Returns: d (dict): 'poiss', 'norm', 'lognorm' give the fit error for each distributi...
python
def DistFitDataset(Dat): """ Given a data matrix, this returns the per-gene fit error for the Poisson, Normal, and Log-Normal distributions. Args: Dat (array): numpy array with shape (genes, cells) Returns: d (dict): 'poiss', 'norm', 'lognorm' give the fit error for each distributi...
[ "def", "DistFitDataset", "(", "Dat", ")", ":", "#Assumes data to be in the form of a numpy matrix ", "(", "r", ",", "c", ")", "=", "Dat", ".", "shape", "Poiss", "=", "np", ".", "zeros", "(", "r", ")", "Norm", "=", "np", ".", "zeros", "(", "r", ")", "Lo...
Given a data matrix, this returns the per-gene fit error for the Poisson, Normal, and Log-Normal distributions. Args: Dat (array): numpy array with shape (genes, cells) Returns: d (dict): 'poiss', 'norm', 'lognorm' give the fit error for each distribution.
[ "Given", "a", "data", "matrix", "this", "returns", "the", "per", "-", "gene", "fit", "error", "for", "the", "Poisson", "Normal", "and", "Log", "-", "Normal", "distributions", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/fit_dist_data.py#L55-L80
moonso/loqusdb
loqusdb/utils/delete.py
delete
def delete(adapter, case_obj, update=False, existing_case=False): """Delete a case and all of it's variants from the database. Args: adapter: Connection to database case_obj(models.Case) update(bool): If we are in the middle of an update existing_case(models.Case): If someth...
python
def delete(adapter, case_obj, update=False, existing_case=False): """Delete a case and all of it's variants from the database. Args: adapter: Connection to database case_obj(models.Case) update(bool): If we are in the middle of an update existing_case(models.Case): If someth...
[ "def", "delete", "(", "adapter", ",", "case_obj", ",", "update", "=", "False", ",", "existing_case", "=", "False", ")", ":", "# This will overwrite the updated case with the previous one", "if", "update", ":", "adapter", ".", "add_case", "(", "existing_case", ")", ...
Delete a case and all of it's variants from the database. Args: adapter: Connection to database case_obj(models.Case) update(bool): If we are in the middle of an update existing_case(models.Case): If something failed during an update we need to revert ...
[ "Delete", "a", "case", "and", "all", "of", "it", "s", "variants", "from", "the", "database", ".", "Args", ":", "adapter", ":", "Connection", "to", "database", "case_obj", "(", "models", ".", "Case", ")", "update", "(", "bool", ")", ":", "If", "we", "...
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/delete.py#L12-L40
moonso/loqusdb
loqusdb/utils/delete.py
delete_variants
def delete_variants(adapter, vcf_obj, case_obj, case_id=None): """Delete variants for a case in the database Args: adapter(loqusdb.plugins.Adapter) vcf_obj(iterable(dict)) ind_positions(dict) case_id(str) Returns: nr_deleted (int): Number of deleted variants...
python
def delete_variants(adapter, vcf_obj, case_obj, case_id=None): """Delete variants for a case in the database Args: adapter(loqusdb.plugins.Adapter) vcf_obj(iterable(dict)) ind_positions(dict) case_id(str) Returns: nr_deleted (int): Number of deleted variants...
[ "def", "delete_variants", "(", "adapter", ",", "vcf_obj", ",", "case_obj", ",", "case_id", "=", "None", ")", ":", "case_id", "=", "case_id", "or", "case_obj", "[", "'case_id'", "]", "nr_deleted", "=", "0", "start_deleting", "=", "datetime", ".", "now", "("...
Delete variants for a case in the database Args: adapter(loqusdb.plugins.Adapter) vcf_obj(iterable(dict)) ind_positions(dict) case_id(str) Returns: nr_deleted (int): Number of deleted variants
[ "Delete", "variants", "for", "a", "case", "in", "the", "database", "Args", ":", "adapter", "(", "loqusdb", ".", "plugins", ".", "Adapter", ")", "vcf_obj", "(", "iterable", "(", "dict", "))", "ind_positions", "(", "dict", ")", "case_id", "(", "str", ")", ...
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/delete.py#L42-L89
moonso/loqusdb
loqusdb/commands/annotate.py
annotate
def annotate(ctx, variant_file, sv): """Annotate the variants in a VCF """ adapter = ctx.obj['adapter'] variant_path = os.path.abspath(variant_file) expected_type = 'snv' if sv: expected_type = 'sv' if 'sv': nr_cases = adapter.nr_cases(sv_cases=True) else: nr_...
python
def annotate(ctx, variant_file, sv): """Annotate the variants in a VCF """ adapter = ctx.obj['adapter'] variant_path = os.path.abspath(variant_file) expected_type = 'snv' if sv: expected_type = 'sv' if 'sv': nr_cases = adapter.nr_cases(sv_cases=True) else: nr_...
[ "def", "annotate", "(", "ctx", ",", "variant_file", ",", "sv", ")", ":", "adapter", "=", "ctx", ".", "obj", "[", "'adapter'", "]", "variant_path", "=", "os", ".", "path", ".", "abspath", "(", "variant_file", ")", "expected_type", "=", "'snv'", "if", "s...
Annotate the variants in a VCF
[ "Annotate", "the", "variants", "in", "a", "VCF" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/annotate.py#L25-L59
bachya/py17track
py17track/track.py
Track.find
async def find(self, *tracking_numbers: str) -> list: """Get tracking info for one or more tracking numbers.""" data = {'data': [{'num': num} for num in tracking_numbers]} tracking_resp = await self._request('post', API_URL_TRACK, json=data) print(tracking_resp) if not tracking...
python
async def find(self, *tracking_numbers: str) -> list: """Get tracking info for one or more tracking numbers.""" data = {'data': [{'num': num} for num in tracking_numbers]} tracking_resp = await self._request('post', API_URL_TRACK, json=data) print(tracking_resp) if not tracking...
[ "async", "def", "find", "(", "self", ",", "*", "tracking_numbers", ":", "str", ")", "->", "list", ":", "data", "=", "{", "'data'", ":", "[", "{", "'num'", ":", "num", "}", "for", "num", "in", "tracking_numbers", "]", "}", "tracking_resp", "=", "await...
Get tracking info for one or more tracking numbers.
[ "Get", "tracking", "info", "for", "one", "or", "more", "tracking", "numbers", "." ]
train
https://github.com/bachya/py17track/blob/e6e64f2a79571433df7ee702cb4ebc4127b7ad6d/py17track/track.py#L17-L44
moonso/loqusdb
loqusdb/commands/cli.py
cli
def cli(ctx, database, username, password, authdb, port, host, uri, verbose, config, test): """loqusdb: manage a local variant count database.""" loglevel = "INFO" if verbose: loglevel = "DEBUG" coloredlogs.install(level=loglevel) LOG.info("Running loqusdb version %s", __version__) conf...
python
def cli(ctx, database, username, password, authdb, port, host, uri, verbose, config, test): """loqusdb: manage a local variant count database.""" loglevel = "INFO" if verbose: loglevel = "DEBUG" coloredlogs.install(level=loglevel) LOG.info("Running loqusdb version %s", __version__) conf...
[ "def", "cli", "(", "ctx", ",", "database", ",", "username", ",", "password", ",", "authdb", ",", "port", ",", "host", ",", "uri", ",", "verbose", ",", "config", ",", "test", ")", ":", "loglevel", "=", "\"INFO\"", "if", "verbose", ":", "loglevel", "="...
loqusdb: manage a local variant count database.
[ "loqusdb", ":", "manage", "a", "local", "variant", "count", "database", "." ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/cli.py#L62-L111
yjzhang/uncurl_python
uncurl/qual2quant.py
binarize
def binarize(qualitative): """ binarizes an expression dataset. """ thresholds = qualitative.min(1) + (qualitative.max(1) - qualitative.min(1))/2.0 binarized = qualitative > thresholds.reshape((len(thresholds), 1)).repeat(8,1) return binarized.astype(int)
python
def binarize(qualitative): """ binarizes an expression dataset. """ thresholds = qualitative.min(1) + (qualitative.max(1) - qualitative.min(1))/2.0 binarized = qualitative > thresholds.reshape((len(thresholds), 1)).repeat(8,1) return binarized.astype(int)
[ "def", "binarize", "(", "qualitative", ")", ":", "thresholds", "=", "qualitative", ".", "min", "(", "1", ")", "+", "(", "qualitative", ".", "max", "(", "1", ")", "-", "qualitative", ".", "min", "(", "1", ")", ")", "/", "2.0", "binarized", "=", "qua...
binarizes an expression dataset.
[ "binarizes", "an", "expression", "dataset", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/qual2quant.py#L43-L49
yjzhang/uncurl_python
uncurl/qual2quant.py
qualNorm_filter_genes
def qualNorm_filter_genes(data, qualitative, pval_threshold=0.05, smoothing=1e-5, eps=1e-5): """ Does qualNorm but returns a filtered gene set, based on a p-value threshold. """ genes, cells = data.shape clusters = qualitative.shape[1] output = np.zeros((genes, clusters)) missing_indices = [...
python
def qualNorm_filter_genes(data, qualitative, pval_threshold=0.05, smoothing=1e-5, eps=1e-5): """ Does qualNorm but returns a filtered gene set, based on a p-value threshold. """ genes, cells = data.shape clusters = qualitative.shape[1] output = np.zeros((genes, clusters)) missing_indices = [...
[ "def", "qualNorm_filter_genes", "(", "data", ",", "qualitative", ",", "pval_threshold", "=", "0.05", ",", "smoothing", "=", "1e-5", ",", "eps", "=", "1e-5", ")", ":", "genes", ",", "cells", "=", "data", ".", "shape", "clusters", "=", "qualitative", ".", ...
Does qualNorm but returns a filtered gene set, based on a p-value threshold.
[ "Does", "qualNorm", "but", "returns", "a", "filtered", "gene", "set", "based", "on", "a", "p", "-", "value", "threshold", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/qual2quant.py#L51-L95
yjzhang/uncurl_python
uncurl/qual2quant.py
qualNorm
def qualNorm(data, qualitative): """ Generates starting points using binarized data. If qualitative data is missing for a given gene, all of its entries should be -1 in the qualitative matrix. Args: data (array): 2d array of genes x cells qualitative (array): 2d array of numerical data - ge...
python
def qualNorm(data, qualitative): """ Generates starting points using binarized data. If qualitative data is missing for a given gene, all of its entries should be -1 in the qualitative matrix. Args: data (array): 2d array of genes x cells qualitative (array): 2d array of numerical data - ge...
[ "def", "qualNorm", "(", "data", ",", "qualitative", ")", ":", "genes", ",", "cells", "=", "data", ".", "shape", "clusters", "=", "qualitative", ".", "shape", "[", "1", "]", "output", "=", "np", ".", "zeros", "(", "(", "genes", ",", "clusters", ")", ...
Generates starting points using binarized data. If qualitative data is missing for a given gene, all of its entries should be -1 in the qualitative matrix. Args: data (array): 2d array of genes x cells qualitative (array): 2d array of numerical data - genes x clusters Returns: Array of...
[ "Generates", "starting", "points", "using", "binarized", "data", ".", "If", "qualitative", "data", "is", "missing", "for", "a", "given", "gene", "all", "of", "its", "entries", "should", "be", "-", "1", "in", "the", "qualitative", "matrix", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/qual2quant.py#L97-L146
yjzhang/uncurl_python
uncurl/qual2quant.py
qualNormGaussian
def qualNormGaussian(data, qualitative): """ Generates starting points using binarized data. If qualitative data is missing for a given gene, all of its entries should be -1 in the qualitative matrix. Args: data (array): 2d array of genes x cells qualitative (array): 2d array of numerical d...
python
def qualNormGaussian(data, qualitative): """ Generates starting points using binarized data. If qualitative data is missing for a given gene, all of its entries should be -1 in the qualitative matrix. Args: data (array): 2d array of genes x cells qualitative (array): 2d array of numerical d...
[ "def", "qualNormGaussian", "(", "data", ",", "qualitative", ")", ":", "genes", ",", "cells", "=", "data", ".", "shape", "clusters", "=", "qualitative", ".", "shape", "[", "1", "]", "output", "=", "np", ".", "zeros", "(", "(", "genes", ",", "clusters", ...
Generates starting points using binarized data. If qualitative data is missing for a given gene, all of its entries should be -1 in the qualitative matrix. Args: data (array): 2d array of genes x cells qualitative (array): 2d array of numerical data - genes x clusters Returns: Array of...
[ "Generates", "starting", "points", "using", "binarized", "data", ".", "If", "qualitative", "data", "is", "missing", "for", "a", "given", "gene", "all", "of", "its", "entries", "should", "be", "-", "1", "in", "the", "qualitative", "matrix", "." ]
train
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/qual2quant.py#L149-L192
OCHA-DAP/hdx-python-country
setup.py
script_dir
def script_dir(pyobject, follow_symlinks=True): """Get current script's directory Args: pyobject (Any): Any Python object in the script follow_symlinks (Optional[bool]): Follow symlinks or not. Defaults to True. Returns: str: Current script's directory """ if getattr(sys, '...
python
def script_dir(pyobject, follow_symlinks=True): """Get current script's directory Args: pyobject (Any): Any Python object in the script follow_symlinks (Optional[bool]): Follow symlinks or not. Defaults to True. Returns: str: Current script's directory """ if getattr(sys, '...
[ "def", "script_dir", "(", "pyobject", ",", "follow_symlinks", "=", "True", ")", ":", "if", "getattr", "(", "sys", ",", "'frozen'", ",", "False", ")", ":", "# py2exe, PyInstaller, cx_Freeze", "path", "=", "abspath", "(", "sys", ".", "executable", ")", "else",...
Get current script's directory Args: pyobject (Any): Any Python object in the script follow_symlinks (Optional[bool]): Follow symlinks or not. Defaults to True. Returns: str: Current script's directory
[ "Get", "current", "script", "s", "directory" ]
train
https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/setup.py#L11-L27
OCHA-DAP/hdx-python-country
setup.py
script_dir_plus_file
def script_dir_plus_file(filename, pyobject, follow_symlinks=True): """Get current script's directory and then append a filename Args: filename (str): Filename to append to directory path pyobject (Any): Any Python object in the script follow_symlinks (Optional[bool]): Follow symlinks o...
python
def script_dir_plus_file(filename, pyobject, follow_symlinks=True): """Get current script's directory and then append a filename Args: filename (str): Filename to append to directory path pyobject (Any): Any Python object in the script follow_symlinks (Optional[bool]): Follow symlinks o...
[ "def", "script_dir_plus_file", "(", "filename", ",", "pyobject", ",", "follow_symlinks", "=", "True", ")", ":", "return", "join", "(", "script_dir", "(", "pyobject", ",", "follow_symlinks", ")", ",", "filename", ")" ]
Get current script's directory and then append a filename Args: filename (str): Filename to append to directory path pyobject (Any): Any Python object in the script follow_symlinks (Optional[bool]): Follow symlinks or not. Defaults to True. Returns: str: Current script's direct...
[ "Get", "current", "script", "s", "directory", "and", "then", "append", "a", "filename" ]
train
https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/setup.py#L30-L41
moonso/loqusdb
loqusdb/commands/identity.py
identity
def identity(ctx, variant_id): """Check how well SVs are working in the database """ if not variant_id: LOG.warning("Please provide a variant id") ctx.abort() adapter = ctx.obj['adapter'] version = ctx.obj['version'] LOG.info("Search variants {0}".format(adapter)) ...
python
def identity(ctx, variant_id): """Check how well SVs are working in the database """ if not variant_id: LOG.warning("Please provide a variant id") ctx.abort() adapter = ctx.obj['adapter'] version = ctx.obj['version'] LOG.info("Search variants {0}".format(adapter)) ...
[ "def", "identity", "(", "ctx", ",", "variant_id", ")", ":", "if", "not", "variant_id", ":", "LOG", ".", "warning", "(", "\"Please provide a variant id\"", ")", "ctx", ".", "abort", "(", ")", "adapter", "=", "ctx", ".", "obj", "[", "'adapter'", "]", "vers...
Check how well SVs are working in the database
[ "Check", "how", "well", "SVs", "are", "working", "in", "the", "database" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/identity.py#L13-L32
ggravlingen/pygleif
pygleif/gleif.py
GLEIFEntity.registration_authority_entity_id
def registration_authority_entity_id(self): """ Some entities return the register entity id, but other do not. Unsure if this is a bug or inconsistently registered data. """ if ATTR_ENTITY_REGISTRATION_AUTHORITY in self.raw: try: return self.r...
python
def registration_authority_entity_id(self): """ Some entities return the register entity id, but other do not. Unsure if this is a bug or inconsistently registered data. """ if ATTR_ENTITY_REGISTRATION_AUTHORITY in self.raw: try: return self.r...
[ "def", "registration_authority_entity_id", "(", "self", ")", ":", "if", "ATTR_ENTITY_REGISTRATION_AUTHORITY", "in", "self", ".", "raw", ":", "try", ":", "return", "self", ".", "raw", "[", "ATTR_ENTITY_REGISTRATION_AUTHORITY", "]", "[", "ATTR_ENTITY_REGISTRATION_AUTHORIT...
Some entities return the register entity id, but other do not. Unsure if this is a bug or inconsistently registered data.
[ "Some", "entities", "return", "the", "register", "entity", "id", "but", "other", "do", "not", ".", "Unsure", "if", "this", "is", "a", "bug", "or", "inconsistently", "registered", "data", "." ]
train
https://github.com/ggravlingen/pygleif/blob/f0f62f1a2878fce45fedcc2260264153808429f9/pygleif/gleif.py#L127-L141
ggravlingen/pygleif
pygleif/gleif.py
GLEIFEntity.legal_form
def legal_form(self): """In some cases, the legal form is stored in the JSON-data. In other cases, an ELF-code, consisting of mix of exactly four letters and numbers are stored. This ELF-code can be looked up in a registry where a code maps to a organizational type. ELF-codes are...
python
def legal_form(self): """In some cases, the legal form is stored in the JSON-data. In other cases, an ELF-code, consisting of mix of exactly four letters and numbers are stored. This ELF-code can be looked up in a registry where a code maps to a organizational type. ELF-codes are...
[ "def", "legal_form", "(", "self", ")", ":", "if", "ATTR_ENTITY_LEGAL_FORM", "in", "self", ".", "raw", ":", "try", ":", "return", "LEGAL_FORMS", "[", "self", ".", "legal_jurisdiction", "]", "[", "self", ".", "raw", "[", "ATTR_ENTITY_LEGAL_FORM", "]", "[", "...
In some cases, the legal form is stored in the JSON-data. In other cases, an ELF-code, consisting of mix of exactly four letters and numbers are stored. This ELF-code can be looked up in a registry where a code maps to a organizational type. ELF-codes are not unique, it can reocc...
[ "In", "some", "cases", "the", "legal", "form", "is", "stored", "in", "the", "JSON", "-", "data", ".", "In", "other", "cases", "an", "ELF", "-", "code", "consisting", "of", "mix", "of", "exactly", "four", "letters", "and", "numbers", "are", "stored", "....
train
https://github.com/ggravlingen/pygleif/blob/f0f62f1a2878fce45fedcc2260264153808429f9/pygleif/gleif.py#L157-L182
ggravlingen/pygleif
pygleif/gleif.py
DirectChild.valid_child_records
def valid_child_records(self): child_lei = list() """Loop through data to find a valid record. Return list of LEI.""" for d in self.raw['data']: # We're not very greedy here, but it seems some records have # lapsed even through the issuer is active if d['att...
python
def valid_child_records(self): child_lei = list() """Loop through data to find a valid record. Return list of LEI.""" for d in self.raw['data']: # We're not very greedy here, but it seems some records have # lapsed even through the issuer is active if d['att...
[ "def", "valid_child_records", "(", "self", ")", ":", "child_lei", "=", "list", "(", ")", "for", "d", "in", "self", ".", "raw", "[", "'data'", "]", ":", "# We're not very greedy here, but it seems some records have", "# lapsed even through the issuer is active", "if", ...
Loop through data to find a valid record. Return list of LEI.
[ "Loop", "through", "data", "to", "find", "a", "valid", "record", ".", "Return", "list", "of", "LEI", "." ]
train
https://github.com/ggravlingen/pygleif/blob/f0f62f1a2878fce45fedcc2260264153808429f9/pygleif/gleif.py#L305-L317
moonso/loqusdb
loqusdb/utils/annotate.py
annotate_variant
def annotate_variant(variant, var_obj=None): """Annotate a cyvcf variant with observations Args: variant(cyvcf2.variant) var_obj(dict) Returns: variant(cyvcf2.variant): Annotated variant """ if var_obj: variant.INFO['Obs'] = var_obj['observations'] ...
python
def annotate_variant(variant, var_obj=None): """Annotate a cyvcf variant with observations Args: variant(cyvcf2.variant) var_obj(dict) Returns: variant(cyvcf2.variant): Annotated variant """ if var_obj: variant.INFO['Obs'] = var_obj['observations'] ...
[ "def", "annotate_variant", "(", "variant", ",", "var_obj", "=", "None", ")", ":", "if", "var_obj", ":", "variant", ".", "INFO", "[", "'Obs'", "]", "=", "var_obj", "[", "'observations'", "]", "if", "var_obj", ".", "get", "(", "'homozygote'", ")", ":", "...
Annotate a cyvcf variant with observations Args: variant(cyvcf2.variant) var_obj(dict) Returns: variant(cyvcf2.variant): Annotated variant
[ "Annotate", "a", "cyvcf", "variant", "with", "observations", "Args", ":", "variant", "(", "cyvcf2", ".", "variant", ")", "var_obj", "(", "dict", ")", "Returns", ":", "variant", "(", "cyvcf2", ".", "variant", ")", ":", "Annotated", "variant" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/annotate.py#L12-L30
moonso/loqusdb
loqusdb/utils/annotate.py
annotate_snv
def annotate_snv(adpter, variant): """Annotate an SNV/INDEL variant Args: adapter(loqusdb.plugin.adapter) variant(cyvcf2.Variant) """ variant_id = get_variant_id(variant) variant_obj = adapter.get_variant(variant={'_id':variant_id}) annotated_variant = annotated_variant...
python
def annotate_snv(adpter, variant): """Annotate an SNV/INDEL variant Args: adapter(loqusdb.plugin.adapter) variant(cyvcf2.Variant) """ variant_id = get_variant_id(variant) variant_obj = adapter.get_variant(variant={'_id':variant_id}) annotated_variant = annotated_variant...
[ "def", "annotate_snv", "(", "adpter", ",", "variant", ")", ":", "variant_id", "=", "get_variant_id", "(", "variant", ")", "variant_obj", "=", "adapter", ".", "get_variant", "(", "variant", "=", "{", "'_id'", ":", "variant_id", "}", ")", "annotated_variant", ...
Annotate an SNV/INDEL variant Args: adapter(loqusdb.plugin.adapter) variant(cyvcf2.Variant)
[ "Annotate", "an", "SNV", "/", "INDEL", "variant", "Args", ":", "adapter", "(", "loqusdb", ".", "plugin", ".", "adapter", ")", "variant", "(", "cyvcf2", ".", "Variant", ")" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/annotate.py#L32-L43
moonso/loqusdb
loqusdb/utils/annotate.py
annotate_svs
def annotate_svs(adapter, vcf_obj): """Annotate all SV variants in a VCF Args: adapter(loqusdb.plugin.adapter) vcf_obj(cyvcf2.VCF) Yields: variant(cyvcf2.Variant) """ for nr_variants, variant in enumerate(vcf_obj, 1): variant_info = get_coords(variant) ...
python
def annotate_svs(adapter, vcf_obj): """Annotate all SV variants in a VCF Args: adapter(loqusdb.plugin.adapter) vcf_obj(cyvcf2.VCF) Yields: variant(cyvcf2.Variant) """ for nr_variants, variant in enumerate(vcf_obj, 1): variant_info = get_coords(variant) ...
[ "def", "annotate_svs", "(", "adapter", ",", "vcf_obj", ")", ":", "for", "nr_variants", ",", "variant", "in", "enumerate", "(", "vcf_obj", ",", "1", ")", ":", "variant_info", "=", "get_coords", "(", "variant", ")", "match", "=", "adapter", ".", "get_structu...
Annotate all SV variants in a VCF Args: adapter(loqusdb.plugin.adapter) vcf_obj(cyvcf2.VCF) Yields: variant(cyvcf2.Variant)
[ "Annotate", "all", "SV", "variants", "in", "a", "VCF", "Args", ":", "adapter", "(", "loqusdb", ".", "plugin", ".", "adapter", ")", "vcf_obj", "(", "cyvcf2", ".", "VCF", ")", "Yields", ":", "variant", "(", "cyvcf2", ".", "Variant", ")" ]
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/annotate.py#L45-L60
moonso/loqusdb
loqusdb/utils/annotate.py
annotate_snvs
def annotate_snvs(adapter, vcf_obj): """Annotate all variants in a VCF Args: adapter(loqusdb.plugin.adapter) vcf_obj(cyvcf2.VCF) Yields: variant(cyvcf2.Variant): Annotated variant """ variants = {} for nr_variants, variant in enumerate(vcf_obj, 1): ...
python
def annotate_snvs(adapter, vcf_obj): """Annotate all variants in a VCF Args: adapter(loqusdb.plugin.adapter) vcf_obj(cyvcf2.VCF) Yields: variant(cyvcf2.Variant): Annotated variant """ variants = {} for nr_variants, variant in enumerate(vcf_obj, 1): ...
[ "def", "annotate_snvs", "(", "adapter", ",", "vcf_obj", ")", ":", "variants", "=", "{", "}", "for", "nr_variants", ",", "variant", "in", "enumerate", "(", "vcf_obj", ",", "1", ")", ":", "# Add the variant to current batch", "variants", "[", "get_variant_id", "...
Annotate all variants in a VCF Args: adapter(loqusdb.plugin.adapter) vcf_obj(cyvcf2.VCF) Yields: variant(cyvcf2.Variant): Annotated variant
[ "Annotate", "all", "variants", "in", "a", "VCF", "Args", ":", "adapter", "(", "loqusdb", ".", "plugin", ".", "adapter", ")", "vcf_obj", "(", "cyvcf2", ".", "VCF", ")", "Yields", ":", "variant", "(", "cyvcf2", ".", "Variant", ")", ":", "Annotated", "var...
train
https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/annotate.py#L63-L97
bosth/plpygis
plpygis/geometry.py
Geometry.from_geojson
def from_geojson(geojson, srid=4326): """ Create a Geometry from a GeoJSON. The SRID can be overridden from the expected 4326. """ type_ = geojson["type"].lower() if type_ == "geometrycollection": geometries = [] for geometry in geojson["geometries...
python
def from_geojson(geojson, srid=4326): """ Create a Geometry from a GeoJSON. The SRID can be overridden from the expected 4326. """ type_ = geojson["type"].lower() if type_ == "geometrycollection": geometries = [] for geometry in geojson["geometries...
[ "def", "from_geojson", "(", "geojson", ",", "srid", "=", "4326", ")", ":", "type_", "=", "geojson", "[", "\"type\"", "]", ".", "lower", "(", ")", "if", "type_", "==", "\"geometrycollection\"", ":", "geometries", "=", "[", "]", "for", "geometry", "in", ...
Create a Geometry from a GeoJSON. The SRID can be overridden from the expected 4326.
[ "Create", "a", "Geometry", "from", "a", "GeoJSON", ".", "The", "SRID", "can", "be", "overridden", "from", "the", "expected", "4326", "." ]
train
https://github.com/bosth/plpygis/blob/9469cc469df4c8cd407de158903d5465cda804ea/plpygis/geometry.py#L77-L102