idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
47,200 | def state_estimation_ensemble ( data , k , n_runs = 10 , M_list = [ ] , ** se_params ) : if len ( M_list ) == 0 : M_list = [ ] for i in range ( n_runs ) : M , W , ll = poisson_estimate_state ( data , k , ** se_params ) M_list . append ( M ) M_stacked = np . hstack ( M_list ) M_new , W_new , ll = poisson_estimate_state ... | Runs an ensemble method on the list of M results ... |
47,201 | def nmf_ensemble ( data , k , n_runs = 10 , W_list = [ ] , ** nmf_params ) : nmf = NMF ( k ) if len ( W_list ) == 0 : W_list = [ ] for i in range ( n_runs ) : W = nmf . fit_transform ( data ) W_list . append ( W ) W_stacked = np . hstack ( W_list ) nmf_w = nmf . fit_transform ( W_stacked ) nmf_h = nmf . components_ H_n... | Runs an ensemble method on the list of NMF W matrices ... |
47,202 | def nmf_tsne ( data , k , n_runs = 10 , init = 'enhanced' , ** params ) : clusters = [ ] nmf = NMF ( k ) tsne = TSNE ( 2 ) km = KMeans ( k ) for i in range ( n_runs ) : w = nmf . fit_transform ( data ) h = nmf . components_ tsne_wh = tsne . fit_transform ( w . dot ( h ) . T ) clust = km . fit_predict ( tsne_wh ) cluste... | runs tsne - consensus - NMF |
47,203 | def poisson_consensus_se ( data , k , n_runs = 10 , ** se_params ) : clusters = [ ] for i in range ( n_runs ) : assignments , means = poisson_cluster ( data , k ) clusters . append ( assignments ) clusterings = np . vstack ( clusters ) consensus = CE . cluster_ensembles ( clusterings , verbose = False , N_clusters_max ... | Initializes Poisson State Estimation using a consensus Poisson clustering . |
47,204 | async def login ( self , email : str , password : str ) -> bool : login_resp = await self . _request ( 'post' , API_URL_USER , json = { 'version' : '1.0' , 'method' : 'Signin' , 'param' : { 'Email' : email , 'Password' : password , 'CaptchaCode' : '' } , 'sourcetype' : 0 } ) _LOGGER . debug ( 'Login response: %s' , log... | Login to the profile . |
47,205 | async def packages ( self , package_state : Union [ int , str ] = '' , show_archived : bool = False ) -> list : packages_resp = await self . _request ( 'post' , API_URL_BUYER , json = { 'version' : '1.0' , 'method' : 'GetTrackInfoList' , 'param' : { 'IsArchived' : show_archived , 'Item' : '' , 'Page' : 1 , 'PerPage' : ... | Get the list of packages associated with the account . |
47,206 | async def summary ( self , show_archived : bool = False ) -> dict : summary_resp = await self . _request ( 'post' , API_URL_BUYER , json = { 'version' : '1.0' , 'method' : 'GetIndexData' , 'param' : { 'IsArchived' : show_archived } , 'sourcetype' : 0 } ) _LOGGER . debug ( 'Summary response: %s' , summary_resp ) results... | Get a quick summary of how many packages are in an account . |
47,207 | def setup_platform ( hass , config , add_entities , discovery_info = None ) : if discovery_info is None : return switches = [ ] manager = hass . data [ DOMAIN ] [ 'manager' ] if manager . outlets is not None and manager . outlets : if len ( manager . outlets ) == 1 : count_string = 'switch' else : count_string = 'switc... | Set up the VeSync switch platform . |
47,208 | def device_state_attributes ( self ) : attr = { } attr [ 'active_time' ] = self . smartplug . active_time attr [ 'voltage' ] = self . smartplug . voltage attr [ 'active_time' ] = self . smartplug . active_time attr [ 'weekly_energy_total' ] = self . smartplug . weekly_energy_total attr [ 'monthly_energy_total' ] = self... | Return the state attributes of the device . |
47,209 | def get_variants ( self , chromosome = None , start = None , end = None ) : query = { } if chromosome : query [ 'chrom' ] = chromosome if start : query [ 'start' ] = { '$lte' : end } query [ 'end' ] = { '$gte' : start } LOG . info ( "Find all variants {}" . format ( query ) ) return self . db . variant . find ( query )... | Return all variants in the database If no region is specified all variants will be returned . |
47,210 | def delete_variant ( self , variant ) : mongo_variant = self . get_variant ( variant ) if mongo_variant : if mongo_variant [ 'observations' ] == 1 : LOG . debug ( "Removing variant {0}" . format ( mongo_variant . get ( '_id' ) ) ) message = self . db . variant . delete_one ( { '_id' : variant [ '_id' ] } ) else : LOG .... | Delete observation in database |
47,211 | def downsample ( data , percent ) : n_genes = data . shape [ 0 ] n_cells = data . shape [ 1 ] new_data = data . copy ( ) total_count = float ( data . sum ( ) ) to_remove = total_count * percent cell_sums = data . sum ( 0 ) . astype ( float ) cell_gene_probs = data / cell_sums cell_probs = np . array ( cell_sums / total... | downsample the data by removing a given percentage of the reads . |
47,212 | 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 ) : data_subset = data . copy ( ) genes , cells = data_subset . shape if R is None : nb_indices = find_nb_genes ( data ) data_subset = data ... | Uses a Negative Binomial Mixture model to estimate cell states and cell state mixing weights . |
47,213 | def cli ( ctx , directory , uri , verbose , count ) : loglevel = "INFO" if verbose : loglevel = "DEBUG" coloredlogs . install ( level = loglevel ) p = Path ( directory ) if not p . is_dir ( ) : LOG . warning ( "{0} is not a valid directory" . format ( directory ) ) ctx . abort ( ) start_time = datetime . now ( ) index_... | Load all files in a directory . |
47,214 | def nmf_init ( data , clusters , k , init = 'enhanced' ) : init_m = np . zeros ( ( data . shape [ 0 ] , k ) ) if sparse . issparse ( data ) : for i in range ( k ) : if data [ : , clusters == i ] . shape [ 1 ] == 0 : point = np . random . randint ( 0 , data . shape [ 1 ] ) init_m [ : , i ] = data [ : , point ] . toarray... | Generates initial M and W given a data set and an array of cluster labels . |
47,215 | def get_variant_id ( variant ) : variant_id = '_' . join ( [ str ( variant . CHROM ) , str ( variant . POS ) , str ( variant . REF ) , str ( variant . ALT [ 0 ] ) ] ) return variant_id | Get a variant id on the format chrom_pos_ref_alt |
47,216 | def migrate ( ctx , ) : 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 . info ( "Nr variants that where updated: %s" , nr_updated ) | Migrate an old loqusdb instance to 1 . 0 |
47,217 | def export ( ctx , outfile , variant_type ) : adapter = ctx . obj [ 'adapter' ] version = ctx . obj [ 'version' ] LOG . info ( "Export the variants from {0}" . format ( adapter ) ) nr_cases = 0 is_sv = variant_type == 'sv' existing_chromosomes = set ( adapter . get_chromosomes ( sv = is_sv ) ) ordered_chromosomes = [ ]... | Export the variants of a loqus db The variants are exported to a vcf file |
47,218 | 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 ) : vcf_files = [ ] nr_variants = None vcf_individuals = Non... | Load the database with a case and its variants |
47,219 | def load_case ( adapter , case_obj , update = False ) : existing_case = adapter . case ( case_obj ) if existing_case : if not update : raise CaseError ( "Case {0} already exists in database" . format ( case_obj [ 'case_id' ] ) ) case_obj = update_case ( case_obj , existing_case ) try : adapter . add_case ( case_obj , u... | Load a case to the database |
47,220 | 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' : nr_variants = case_obj [ 'nr_variants' ] else : nr_variants = case_obj [ 'nr_sv_variants' ] nr_inserted = 0 case_id = case_obj [ 'case_id' ] if skip_case... | Load variants for a family into the database . |
47,221 | def max_variance_genes ( data , nbins = 5 , frac = 0.2 ) : indices = [ ] if sparse . issparse ( data ) : means , var = sparse_mean_var ( data ) else : means = data . mean ( 1 ) var = data . var ( 1 ) mean_indices = means . argsort ( ) n_elements = int ( data . shape [ 0 ] / nbins ) frac_elements = int ( n_elements * fr... | This function identifies the genes that have the max variance across a number of bins sorted by mean . |
47,222 | def cell_normalize ( data ) : if sparse . issparse ( data ) : data = sparse . csc_matrix ( data . astype ( float ) ) sparse_cell_normalize ( data . data , data . indices , data . indptr , data . shape [ 1 ] , data . shape [ 0 ] ) return data data_norm = data . astype ( float ) total_umis = [ ] for i in range ( data . s... | Returns the data where the expression is normalized so that the total count per cell is equal . |
47,223 | 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 |
47,224 | 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 ) : individual_positions = get_individual_positions ( vcf_individuals ) sv_individual_posit... | Build a Case from the given information |
47,225 | def generate_poisson_data ( centers , n_cells , cluster_probs = None ) : genes , clusters = centers . shape output = np . zeros ( ( genes , n_cells ) ) if cluster_probs is None : cluster_probs = np . ones ( clusters ) / clusters labels = [ ] for i in range ( n_cells ) : c = np . random . choice ( range ( clusters ) , p... | Generates poisson - distributed data given a set of means for each cluster . |
47,226 | def generate_zip_data ( M , L , n_cells , cluster_probs = None ) : genes , clusters = M . shape output = np . zeros ( ( genes , n_cells ) ) if cluster_probs is None : cluster_probs = np . ones ( clusters ) / clusters zip_p = np . random . random ( ( genes , n_cells ) ) labels = [ ] for i in range ( n_cells ) : c = np .... | Generates zero - inflated poisson - distributed data given a set of means and zero probs for each cluster . |
47,227 | def generate_state_data ( means , weights ) : x_true = np . dot ( means , weights ) sample = np . random . poisson ( x_true ) return sample . astype ( float ) | Generates data according to the Poisson Convex Mixture Model . |
47,228 | def generate_zip_state_data ( means , weights , z ) : x_true = np . dot ( means , weights ) sample = np . random . poisson ( x_true ) random = np . random . random ( x_true . shape ) x_true [ random < z ] = 0 return sample . astype ( float ) | Generates data according to the Zero - inflated Poisson Convex Mixture Model . |
47,229 | def generate_nb_state_data ( means , weights , R ) : cells = weights . shape [ 1 ] x_true = np . dot ( means , weights ) R_ = np . tile ( R , ( cells , 1 ) ) . T P_true = x_true / ( R_ + x_true ) sample = np . random . negative_binomial ( np . tile ( R , ( cells , 1 ) ) . T , P_true ) return sample . astype ( float ) | Generates data according to the Negative Binomial Convex Mixture Model . |
47,230 | def generate_poisson_lineage ( n_states , n_cells_per_cluster , n_genes , means = 300 ) : M = np . random . random ( ( n_genes , n_states ) ) * means center = M . mean ( 1 ) W = np . zeros ( ( n_states , n_cells_per_cluster * n_states ) ) index = 0 means = np . array ( [ 1.0 / n_states ] * n_states ) for c in range ( n... | Generates a lineage for each state - assumes that each state has a common ancestor . |
47,231 | def generate_nb_data ( P , R , n_cells , assignments = None ) : genes , clusters = P . shape output = np . zeros ( ( genes , n_cells ) ) if assignments is None : cluster_probs = np . ones ( clusters ) / clusters labels = [ ] for i in range ( n_cells ) : if assignments is None : c = np . random . choice ( range ( cluste... | Generates negative binomial data |
47,232 | def visualize_poisson_w ( w , labels , filename , method = 'pca' , figsize = ( 18 , 10 ) , title = '' , ** scatter_options ) : if method == 'pca' : pca = PCA ( 2 ) r_dim_red = pca . fit_transform ( w . T ) . T elif method == 'tsne' : pass else : print ( "Method is not available. use 'pca' (default) or 'tsne'." ) return... | Saves a scatter plot of a visualization of W the result from Poisson SE . |
47,233 | def generate_visualizations ( methods , data , true_labels , base_dir = 'visualizations' , figsize = ( 18 , 10 ) , ** scatter_options ) : plt . figure ( figsize = figsize ) for method in methods : preproc = method [ 0 ] if isinstance ( preproc , Preprocess ) : preprocessed , ll = preproc . run ( data ) output_names = p... | Generates visualization scatters for all the methods . |
47,234 | 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 : for new_device in updated_list : was_found = False for device in orig_list : if new_device . cid == device . cid : was_found = True break if not was_found : orig_list ... | Merges changes from one list of devices against another |
47,235 | def get_profiles ( adapter , vcf_file ) : vcf = get_file_handle ( vcf_file ) individuals = vcf . samples profiles = { individual : [ ] for individual in individuals } for profile_variant in adapter . profile_variants ( ) : ref = profile_variant [ 'ref' ] alt = profile_variant [ 'alt' ] pos = profile_variant [ 'pos' ] e... | Given a vcf get a profile string for each sample in the vcf based on the profile variants in the database |
47,236 | def profile_match ( adapter , profiles , hard_threshold = 0.95 , soft_threshold = 0.9 ) : matches = { sample : [ ] for sample in profiles . keys ( ) } for case in adapter . cases ( ) : for individual in case [ 'individuals' ] : for sample in profiles . keys ( ) : if individual . get ( 'profile' ) : similarity = compare... | 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 . |
47,237 | def compare_profiles ( profile1 , profile2 ) : length = len ( profile1 ) profile1 = np . array ( list ( profile1 ) ) profile2 = np . array ( list ( profile2 ) ) similarity_array = profile1 == profile2 matches = np . sum ( similarity_array ) similarity_ratio = matches / length return similarity_ratio | Given two profiles determine the ratio of similarity i . e . the hamming distance between the strings . |
47,238 | def update_profiles ( adapter ) : for case in adapter . cases ( ) : if case . get ( 'profile_path' ) : profiles = get_profiles ( adapter , case [ 'profile_path' ] ) profiled_individuals = deepcopy ( case [ 'individuals' ] ) for individual in profiled_individuals : ind_id = individual [ 'ind_id' ] try : profile = profil... | For all cases having vcf_path update the profile string for the samples |
47,239 | def profile_stats ( adapter , threshold = 0.9 ) : profiles = [ ] samples = [ ] distance_dict = { key : 0 for key in HAMMING_RANGES . keys ( ) } for case in adapter . cases ( ) : for individual in case [ 'individuals' ] : if individual . get ( 'profile' ) : sample_id = f"{case['case_id']}.{individual['ind_id']}" ind_pro... | Compares the pairwise hamming distances for all the sample profiles in the database . Returns a table of the number of distances within given ranges . |
47,240 | def purity ( labels , true_labels ) : purity = 0.0 for i in set ( labels ) : indices = ( labels == i ) true_clusters = true_labels [ indices ] if len ( true_clusters ) == 0 : continue counts = Counter ( true_clusters ) lab , count = counts . most_common ( ) [ 0 ] purity += count return float ( purity ) / len ( labels ) | Calculates the purity score for the given labels . |
47,241 | def mdl ( ll , k , data ) : N , m = data . shape cost = ll + ( N * m + m * k ) * ( np . log ( data . sum ( ) / ( N * k ) ) ) return cost | Returns the minimum description length score of the model given its log - likelihood and k the number of cell types . |
47,242 | 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 . |
47,243 | def nb_ll ( data , P , R ) : genes , cells = data . shape clusters = P . shape [ 1 ] lls = np . zeros ( ( cells , clusters ) ) for c in range ( clusters ) : P_c = P [ : , c ] . reshape ( ( genes , 1 ) ) R_c = R [ : , c ] . reshape ( ( genes , 1 ) ) ll = gammaln ( R_c + data ) - gammaln ( R_c ) ll += data * np . log ( P... | Returns the negative binomial log - likelihood of the data . |
47,244 | def zinb_ll ( data , P , R , Z ) : lls = nb_ll ( data , P , R ) clusters = P . shape [ 1 ] for c in range ( clusters ) : pass return lls | Returns the zero - inflated negative binomial log - likelihood of the data . |
47,245 | def nb_ll_row ( params , data_row ) : p = params [ 0 ] r = params [ 1 ] n = len ( data_row ) ll = np . sum ( gammaln ( data_row + r ) ) - np . sum ( gammaln ( data_row + 1 ) ) ll -= n * gammaln ( r ) ll += np . sum ( data_row ) * np . log ( p ) ll += n * r * np . log ( 1 - p ) return - ll | returns the negative LL of a single row . |
47,246 | def nb_fit ( data , P_init = None , R_init = None , epsilon = 1e-8 , max_iters = 100 ) : means = data . mean ( 1 ) variances = data . var ( 1 ) if ( means > variances ) . any ( ) : raise ValueError ( "For NB fit, means must be less than variances" ) genes , cells = data . shape P = 1.0 - means / variances R = means * (... | Fits the NB distribution to data using method of moments . |
47,247 | def nb_cluster ( data , k , P_init = None , R_init = None , assignments = None , means = None , max_iters = 10 ) : genes , cells = data . shape if P_init is None : P_init = np . random . random ( ( genes , k ) ) if R_init is None : R_init = np . random . randint ( 1 , data . max ( ) , ( genes , k ) ) R_init = 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 . |
47,248 | def zip_ll ( data , means , M ) : genes , cells = data . shape clusters = means . shape [ 1 ] ll = np . zeros ( ( cells , clusters ) ) d0 = ( data == 0 ) d1 = ( data > 0 ) for i in range ( clusters ) : means_i = np . tile ( means [ : , i ] , ( cells , 1 ) ) means_i = means_i . transpose ( ) L_i = np . tile ( M [ : , i ... | Calculates the zero - inflated Poisson log - likelihood . |
47,249 | def zip_ll_row ( params , data_row ) : l = params [ 0 ] pi = params [ 1 ] d0 = ( data_row == 0 ) likelihood = d0 * pi + ( 1 - pi ) * poisson . pmf ( data_row , l ) return - np . log ( likelihood + eps ) . sum ( ) | Returns the negative log - likelihood of a row given ZIP data . |
47,250 | def preproc_data ( data , gene_subset = False , ** kwargs ) : import uncurl from uncurl . preprocessing import log1p , cell_normalize from sklearn . decomposition import TruncatedSVD data_subset = data if gene_subset : gene_subset = uncurl . max_variance_genes ( data ) data_subset = data [ gene_subset , : ] tsvd = Trun... | basic data preprocessing before running gap score |
47,251 | 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 . |
47,252 | 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 = [ ] sk_vals = [ ] k_range = list ( range ( k_min , k_max , skip ) ) min_k = 0 min_i = 0 for i , k in enumerate ( k_range ) : km = KMeans ( k ) clusters = km . fit_predict ( data ) gap ,... | Runs gap score for all k from k_min to k_max . |
47,253 | def get_devices ( self ) -> list : if not self . enabled : return None self . in_process = True response , _ = helpers . call_api ( '/cloud/v1/deviceManaged/devices' , 'post' , headers = helpers . req_headers ( self ) , json = helpers . req_body ( self , 'devicelist' ) ) if response and helpers . check_response ( respo... | Return list of VeSync devices |
47,254 | def login ( self ) -> bool : 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 ( '/cloud/v1/user/login' , 'post' , json = helpers . req_body ... | Return True if log in request succeeds |
47,255 | def update ( self ) : 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 = helpers . resolve_updates ( self . switches , switches ) self . fans = helpers . resolve_updates... | Fetch updated information about devices |
47,256 | def update_energy ( self , bypass_check = False ) : for outlet in self . outlets : outlet . update_energy ( bypass_check ) | Fetch updated energy information about devices |
47,257 | def DistFitDataset ( Dat ) : ( r , c ) = Dat . shape Poiss = np . zeros ( r ) Norm = np . zeros ( r ) LogNorm = np . zeros ( r ) for i in range ( r ) : temp = GetDistFitError ( Dat [ i ] ) Poiss [ i ] = temp [ 'poiss' ] Norm [ i ] = temp [ 'norm' ] LogNorm [ i ] = temp [ 'lognorm' ] d = { } d [ 'poiss' ] = Poiss d [ 'n... | Given a data matrix this returns the per - gene fit error for the Poisson Normal and Log - Normal distributions . |
47,258 | def annotate ( ctx , variant_file , sv ) : 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_cases = adapter . nr_cases ( snv_cases = True ) LOG . info ( "Found {0... | Annotate the variants in a VCF |
47,259 | async def find ( self , * tracking_numbers : str ) -> list : 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_resp . get ( 'dat' ) : raise InvalidTrackingNumberError ( 'Invalid data'... | Get tracking info for one or more tracking numbers . |
47,260 | def binarize ( qualitative ) : 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 ) | binarizes an expression dataset . |
47,261 | def qualNorm_filter_genes ( data , qualitative , pval_threshold = 0.05 , smoothing = 1e-5 , eps = 1e-5 ) : genes , cells = data . shape clusters = qualitative . shape [ 1 ] output = np . zeros ( ( genes , clusters ) ) missing_indices = [ ] genes_included = [ ] qual_indices = [ ] thresholds = qualitative . min ( 1 ) + (... | Does qualNorm but returns a filtered gene set based on a p - value threshold . |
47,262 | def script_dir ( pyobject , follow_symlinks = True ) : if getattr ( sys , 'frozen' , False ) : path = abspath ( sys . executable ) else : path = inspect . getabsfile ( pyobject ) if follow_symlinks : path = realpath ( path ) return dirname ( path ) | Get current script s directory |
47,263 | 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 |
47,264 | def identity ( ctx , variant_id ) : 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 ) ) result = adapter . get_clusters ( variant_id ) if result . count ( ) == 0 ... | Check how well SVs are working in the database |
47,265 | 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_AUTHORITY_ENTITY_ID ] [ ATTR_DOLLAR_SIGN ] except KeyError : pass | Some entities return the register entity id but other do not . Unsure if this is a bug or inconsistently registered data . |
47,266 | 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 ] [ ATTR_ENTITY_LEGAL_FORM_CODE ] [ ATTR_DOLLAR_SIGN ] ] except KeyError : legal_form = self . raw [ ATTR_ENTITY_LEGAL_FORM ] [ ATTR_ENTITY_LEGAL_FORM_CODE ] [... | 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 reoccur under different names in diffe... |
47,267 | def valid_child_records ( self ) : child_lei = list ( ) for d in self . raw [ 'data' ] : if d [ 'attributes' ] [ 'relationship' ] [ 'status' ] in [ 'ACTIVE' ] : child_lei . append ( d [ 'attributes' ] [ 'relationship' ] [ 'startNode' ] [ 'id' ] ) return child_lei | Loop through data to find a valid record . Return list of LEI . |
47,268 | def from_geojson ( geojson , srid = 4326 ) : type_ = geojson [ "type" ] . lower ( ) if type_ == "geometrycollection" : geometries = [ ] for geometry in geojson [ "geometries" ] : geometries . append ( Geometry . from_geojson ( geometry , srid = None ) ) return GeometryCollection ( geometries , srid ) elif type_ == "poi... | Create a Geometry from a GeoJSON . The SRID can be overridden from the expected 4326 . |
47,269 | def from_shapely ( sgeom , srid = None ) : if SHAPELY : WKBWriter . defaults [ "include_srid" ] = True if srid : lgeos . GEOSSetSRID ( sgeom . _geom , srid ) return Geometry ( sgeom . wkb_hex ) else : raise DependencyError ( "Shapely" ) | Create a Geometry from a Shapely geometry and the specified SRID . |
47,270 | def postgis_type ( self ) : dimz = "Z" if self . dimz else "" dimm = "M" if self . dimm else "" if self . srid : return "geometry({}{}{},{})" . format ( self . type , dimz , dimm , self . srid ) else : return "geometry({}{}{})" . format ( self . type , dimz , dimm ) | Get the type of the geometry in PostGIS format including additional dimensions and SRID if they exist . |
47,271 | def poisson_ll ( data , means ) : if sparse . issparse ( data ) : return sparse_poisson_ll ( data , means ) genes , cells = data . shape clusters = means . shape [ 1 ] ll = np . zeros ( ( cells , clusters ) ) for i in range ( clusters ) : means_i = np . tile ( means [ : , i ] , ( cells , 1 ) ) means_i = means_i . trans... | Calculates the Poisson log - likelihood . |
47,272 | def poisson_dist ( p1 , p2 ) : p1_ = p1 + eps p2_ = p2 + eps return np . dot ( p1_ - p2_ , np . log ( p1_ / p2_ ) ) | Calculates the Poisson distance between two vectors . |
47,273 | def delete ( ctx , family_file , family_type , case_id ) : if not ( family_file or case_id ) : LOG . error ( "Please provide a family file" ) ctx . abort ( ) adapter = ctx . obj [ 'adapter' ] family = None family_id = None if family_file : with open ( family_file , 'r' ) as family_lines : family = get_case ( family_lin... | Delete the variants of a case . |
47,274 | def update_energy ( self , bypass_check : bool = False ) : if bypass_check or ( not bypass_check and self . update_time_check ) : self . get_weekly_energy ( ) if 'week' in self . energy : self . get_monthly_energy ( ) self . get_yearly_energy ( ) if not bypass_check : self . update_energy_ts = time . time ( ) | Builds weekly monthly and yearly dictionaries |
47,275 | def turn_on_nightlight ( self ) : body = helpers . req_body ( self . manager , 'devicestatus' ) body [ 'uuid' ] = self . uuid body [ 'mode' ] = 'auto' response , _ = helpers . call_api ( '/15a/v1/device/nightlightstatus' , 'put' , headers = helpers . req_headers ( self . manager ) , json = body ) return helpers . check... | Turn on nightlight |
47,276 | def like_button_js_tag ( context ) : if FACEBOOK_APP_ID is None : log . warning ( "FACEBOOK_APP_ID isn't setup correctly in your settings" ) if FACEBOOK_APP_ID : request = context . get ( 'request' , None ) if request : return { "LIKE_BUTTON_IS_VALID" : True , "facebook_app_id" : FACEBOOK_APP_ID , "channel_base_url" : ... | This tag will check to see if they have the FACEBOOK_LIKE_APP_ID setup correctly in the django settings if so then it will pass the data along to the intercom_tag template to be displayed . |
47,277 | def like_button_tag ( context ) : if FACEBOOK_APP_ID is None : log . warning ( "FACEBOOK_APP_ID isn't setup correctly in your settings" ) if FACEBOOK_APP_ID : request = context . get ( 'request' , None ) if request : path_to_like = ( "http://" + request . get_host ( ) + request . get_full_path ( ) ) show_send = true_fa... | This tag will check to see if they have the FACEBOOK_APP_ID setup correctly in the django settings if so then it will pass the data along to the intercom_tag template to be displayed . |
47,278 | def get_structural_variant ( self , variant ) : query = { 'chrom' : variant [ 'chrom' ] , 'end_chrom' : variant [ 'end_chrom' ] , 'sv_type' : variant [ 'sv_type' ] , '$and' : [ { 'pos_left' : { '$lte' : variant [ 'pos' ] } } , { 'pos_right' : { '$gte' : variant [ 'pos' ] } } , ] } res = self . db . structural_variant .... | Check if there are any overlapping sv clusters |
47,279 | def get_sv_variants ( self , chromosome = None , end_chromosome = None , sv_type = None , pos = None , end = None ) : query = { } if chromosome : query [ 'chrom' ] = chromosome if end_chromosome : query [ 'end_chrom' ] = end_chromosome if sv_type : query [ 'sv_type' ] = sv_type if pos : if not '$and' in query : query [... | Return all structural variants in the database |
47,280 | def get_details ( self ) : body = helpers . req_body ( self . manager , 'devicedetail' ) head = helpers . req_headers ( self . manager ) r , _ = helpers . call_api ( '/131airpurifier/v1/device/deviceDetail' , method = 'post' , headers = head , json = body ) if r is not None and helpers . check_response ( r , 'airpur_de... | Build details dictionary |
47,281 | def turn_on ( self ) : if self . device_status != 'on' : body = helpers . req_body ( self . manager , 'devicestatus' ) body [ 'uuid' ] = self . uuid body [ 'status' ] = 'on' head = helpers . req_headers ( self . manager ) r , _ = helpers . call_api ( '/131airPurifier/v1/device/deviceStatus' , 'put' , json = body , head... | Turn Air Purifier on |
47,282 | def fan_speed ( self , speed : int = None ) -> bool : body = helpers . req_body ( self . manager , 'devicestatus' ) body [ 'uuid' ] = self . uuid head = helpers . req_headers ( self . manager ) if self . details . get ( 'mode' ) != 'manual' : self . mode_toggle ( 'manual' ) else : if speed is not None : level = int ( s... | Adjust Fan Speed by Specifying 1 2 3 as argument or cycle through speeds increasing by one |
47,283 | def mode_toggle ( self , mode : str ) -> bool : head = helpers . req_headers ( self . manager ) body = helpers . req_body ( self . manager , 'devicestatus' ) body [ 'uuid' ] = self . uuid if mode != body [ 'mode' ] and mode in [ 'sleep' , 'auto' , 'manual' ] : body [ 'mode' ] = mode if mode == 'manual' : body [ 'level'... | Set mode to manual auto or sleep |
47,284 | def fourier_series ( x , * a ) : output = 0 output += a [ 0 ] / 2 w = a [ 1 ] for n in range ( 2 , len ( a ) , 2 ) : n_ = n / 2 val1 = a [ n ] val2 = a [ n + 1 ] output += val1 * np . sin ( n_ * x * w ) output += val2 * np . cos ( n_ * x * w ) return output | Arbitrary dimensionality fourier series . |
47,285 | def poly_curve ( x , * a ) : output = 0.0 for n in range ( 0 , len ( a ) ) : output += a [ n ] * x ** n return output | Arbitrary dimension polynomial . |
47,286 | def set_ocha_url ( cls , url = None ) : if url is None : url = cls . _ochaurl_int cls . _ochaurl = url | Set World Bank url from which to retrieve countries data |
47,287 | def get_country_info_from_iso3 ( cls , iso3 , use_live = True , exception = None ) : countriesdata = cls . countriesdata ( use_live = use_live ) country = countriesdata [ 'countries' ] . get ( iso3 . upper ( ) ) if country is not None : return country if exception is not None : raise exception return None | Get country information from ISO3 code |
47,288 | def get_country_name_from_iso3 ( cls , iso3 , use_live = True , exception = None ) : countryinfo = cls . get_country_info_from_iso3 ( iso3 , use_live = use_live , exception = exception ) if countryinfo is not None : return countryinfo . get ( '#country+name+preferred' ) return None | Get country name from ISO3 code |
47,289 | def get_iso2_from_iso3 ( cls , iso3 , use_live = True , exception = None ) : countriesdata = cls . countriesdata ( use_live = use_live ) iso2 = countriesdata [ 'iso2iso3' ] . get ( iso3 . upper ( ) ) if iso2 is not None : return iso2 if exception is not None : raise exception return None | Get ISO2 from ISO3 code |
47,290 | def get_m49_from_iso3 ( cls , iso3 , use_live = True , exception = None ) : countriesdata = cls . countriesdata ( use_live = use_live ) m49 = countriesdata [ 'm49iso3' ] . get ( iso3 ) if m49 is not None : return m49 if exception is not None : raise exception return None | Get M49 from ISO3 code |
47,291 | def simplify_countryname ( cls , country ) : countryupper = country . upper ( ) words = get_words_in_sentence ( countryupper ) index = countryupper . find ( ',' ) if index != - 1 : countryupper = countryupper [ : index ] index = countryupper . find ( ':' ) if index != - 1 : countryupper = countryupper [ : index ] regex... | Simplifies country name by removing descriptive text eg . DEMOCRATIC REPUBLIC OF etc . |
47,292 | def get_iso3_country_code ( cls , country , use_live = True , exception = None ) : countriesdata = cls . countriesdata ( use_live = use_live ) countryupper = country . upper ( ) len_countryupper = len ( countryupper ) if len_countryupper == 3 : if countryupper in countriesdata [ 'countries' ] : return countryupper elif... | Get ISO3 code for cls . Only exact matches or None are returned . |
47,293 | def get_iso3_country_code_fuzzy ( cls , country , use_live = True , exception = None ) : countriesdata = cls . countriesdata ( use_live = use_live ) iso3 = cls . get_iso3_country_code ( country , use_live = use_live ) if iso3 is not None : return iso3 , True def remove_matching_from_list ( wordlist , word_or_part ) : f... | Get ISO3 code for cls . A tuple is returned with the first value being the ISO3 code and the second showing if the match is exact or not . |
47,294 | def load_profile ( ctx , variant_file , update , stats , profile_threshold ) : adapter = ctx . obj [ 'adapter' ] if variant_file : load_profile_variants ( adapter , variant_file ) if update : update_profiles ( adapter ) if stats : distance_dict = profile_stats ( adapter , threshold = profile_threshold ) click . echo ( ... | Command for profiling of samples . User may upload variants used in profiling from a vcf update the profiles for all samples and get some stats from the profiles in the database . |
47,295 | def add_profile_variants ( self , profile_variants ) : results = self . db . profile_variant . insert_many ( profile_variants ) return results | Add several variants to the profile_variant collection in the database |
47,296 | def zip_fit_params ( data ) : genes , cells = data . shape m = data . mean ( 1 ) v = data . var ( 1 ) M = ( v - m ) / ( m ** 2 + v - m ) M = np . array ( [ min ( 1.0 , max ( 0.0 , x ) ) for x in M ] ) L = m + v / m - 1.0 L [ np . isnan ( L ) ] = 0.0 L = np . array ( [ max ( 0.0 , x ) for x in L ] ) return L , M | Returns the ZIP parameters that best fit a given data set . |
47,297 | def zip_cluster ( data , k , init = None , max_iters = 100 ) : genes , cells = data . shape init , new_assignments = kmeans_pp ( data + eps , k , centers = init ) centers = np . copy ( init ) M = np . zeros ( centers . shape ) assignments = new_assignments for c in range ( k ) : centers [ : , c ] , M [ : , c ] = zip_fi... | Performs hard EM clustering using the zero - inflated Poisson distribution . |
47,298 | def diffusion_mds ( means , weights , d , diffusion_rounds = 10 ) : for i in range ( diffusion_rounds ) : weights = weights * weights weights = weights / weights . sum ( 0 ) X = dim_reduce ( means , weights , d ) if X . shape [ 0 ] == 2 : return X . dot ( weights ) else : return X . T . dot ( weights ) | Dimensionality reduction using MDS while running diffusion on W . |
47,299 | def mds ( means , weights , d ) : X = dim_reduce ( means , weights , d ) if X . shape [ 0 ] == 2 : return X . dot ( weights ) else : return X . T . dot ( weights ) | Dimensionality reduction using MDS . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.