Copies gene bias values and weights to network bias values and
        weights.
328423
def unArrayify(self, gene):
        
        g = 0
        # if gene is too small an IndexError will be thrown
        for layer in self.layers:
            if layer.type != 'Input':
                for i in range(layer.size):
                    layer.weight[i] = float( gene[g])
                    g += 1
        for connection in self.connections:
            for i in range(connection.fromLayer.size):
                for j in range(connection.toLayer.size):
                    connection.weight[i][j] = gene[g]
                    g += 1
        # if gene is too long we may have a problem
        if len(gene) > g:
            raise IndexError('Argument to unArrayify is too long.', len(gene))
1113574
def enrich_rnas_with_genes(graph):
    
    for rna_node in list(graph):
        if rna_node[FUNCTION] not in {MIRNA, RNA} or FUSION in rna_node or VARIANTS in rna_node:
            continue

        gene_node = rna_node.get_gene()
        graph.add_transcription(gene_node, rna_node)
603006
def _balanced_strand_gen(base_aligns, limit):
    ''''''
    predicate=lambda align: align.is_reverse
    gen1, gen2 = itertools.tee((predicate(align), align) for align in base_aligns)
    for_strand_gen = (align for pred, align in gen1 if not pred)
    rev_strand_gen = (align for pred, align in gen2 if pred)
    combined_gen = iter_zip(for_strand_gen, rev_strand_gen)
    interleaved_gen = (align for for_rev_aligns in combined_gen for align in for_rev_aligns)
    return itertools.islice(interleaved_gen, limit)
1098899
def make_graph(node, inputs):
        
        initializer = []
        tensor_input_info = []
        tensor_output_info = []

        # Adding input tensor info.
        for index in range(len(node.input)):
            tensor_input_info.append(
                helper.make_tensor_value_info(str(node.input[index]), TensorProto.FLOAT, [1]))

            # Creating an initializer for Weight params.
            # Assumes that weight params is named as 'W'.
            # TODO: Handle multiple weight params.
            # TODO: Add for "bias" if needed
            if node.input[index] == 'W':
                dim = inputs[index].shape
                param_tensor = helper.make_tensor(
                    name=node.input[index],
                    data_type=TensorProto.FLOAT,
                    dims=dim,
                    vals=inputs[index].flatten())

                initializer.append(param_tensor)

        # Adding output tensor info.
        for index in range(len(node.output)):
            tensor_output_info.append(
                helper.make_tensor_value_info(str(node.output[index]), TensorProto.FLOAT, [1]))

        # creating graph proto object.
        graph_proto = helper.make_graph(
            [node],
            "test",
            tensor_input_info,
            tensor_output_info,
            initializer=initializer)

        return graph_proto
739754
def set_weights(params, new_params):
        
        for param, new_param in zip(params, new_params):
            param.data.copy_(new_param.data)
532956
def get_gene2binvec(self):
        """"""
        _sec2chr = self.sec2chr
        return {g:[s in s2gos for s in _sec2chr] for g, s2gos in self.gene2section2gos.items()}
833505
def normalize_genotypes(genotypes):
    
    genotypes = genotypes.genotypes
    return (genotypes - np.nanmean(genotypes)) / np.nanstd(genotypes)
488365
public static void fpropMiniBatch(long seed, Neurons[] neurons, DeepLearningModelInfo minfo,
                                    DeepLearningModelInfo consensus_minfo, boolean training, double[] responses, double[] offset, int n) {
    // Forward propagation
    for (int i=1; i<neurons.length; ++i)
      neurons[i].fprop(seed, training, n);

    // Add offset (in link space) if applicable
    for (int mb=0;mb<n;++mb) {
      if (offset!=null && offset[mb] > 0) {
        assert (!minfo._classification); // Regression
        double[] m = minfo.data_info()._normRespMul;
        double[] s = minfo.data_info()._normRespSub;
        double mul = m == null ? 1 : m[0];
        double sub = s == null ? 0 : s[0];
        neurons[neurons.length - 1]._a[mb].add(0, ((offset[mb] - sub) * mul));
      }

      if (training) {
        // Compute the gradient at the output layer
        // auto-encoder: pass a dummy "response" (ignored)
        // otherwise: class label or regression target
        neurons[neurons.length - 1].setOutputLayerGradient(responses[mb], mb, n);

        // Elastic Averaging - set up helpers needed during back-propagation
        if (consensus_minfo != null) {
          for (int i = 1; i < neurons.length; i++) {
            neurons[i]._wEA = consensus_minfo.get_weights(i - 1);
            neurons[i]._bEA = consensus_minfo.get_biases(i - 1);
          }
        }
      }
    }
  }
1231775
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)+eps
    #temp = X/d
    #w_sum = w.sum(1)
    #w2 = w.dot(temp.T)
    #deriv = w_sum - w2.T
    return np.sum(d - X*np.log(d))/genes
842765
def _apply_correction_on_genes(genes,
                               pathway_column_names,
                               pathway_definitions):
    
    gene_row_names = index_element_map(genes)
    membership_matrix = initialize_membership_matrix(
        genes, pathway_definitions)
    crosstalk_corrected_index_map = maximum_impact_estimation(
        membership_matrix)

    updated_pathway_definitions = _update_pathway_definitions(
        crosstalk_corrected_index_map,
        gene_row_names, pathway_column_names)
    return updated_pathway_definitions
586036
def _fix_bias_shape(self, op_name, inputs, attrs):
        """"""
        if (op_name == 'Add' or op_name == 'Mul') and (int(len(self._params)) > 0) and \
                ('broadcast' in attrs and attrs['broadcast'] == 1):
            assert len(list(inputs)) == 2
            bias_name = self._renames.get(inputs[1], inputs[1])
            bias = self._params[bias_name]
            assert len(bias.shape) == 1
            # reshape to (1, n)
            bias = mx.nd.array(bias.asnumpy().reshape((1, -1, 1, 1)))
            # broadcast_add expects shape with sym.variable
            self._nodes[bias_name] = mx.sym.Variable(name=bias_name, shape=bias.shape)
            self._params[bias_name] = bias
783977
def gen_weights(self, f_target): 
        

        # calculate x and psi   
        x_track = self.cs.rollout()
        psi_track = self.gen_psi(x_track)

        #efficiently calculate weights for BFs using weighted linear regression
        for d in range(self.dmps):
            for b in range(self.bfs): 
                self.w[d,b] = np.dot(psi_track[:,b], f_target[:,d]) / \
                              (np.sum(psi_track[:,b]) + 1e-10)
1370946
public void copyTo(Gradient g) {
		g.numKnots = numKnots;
		g.map = (int[])map.clone();
		g.xKnots = (int[])xKnots.clone();
		g.yKnots = (int[])yKnots.clone();
		g.knotTypes = (byte[])knotTypes.clone();
	}
44543
def copy(self):
        """"""
        health = self.health, self.health_max
        r = self.r, self.r_max
        g = self.g, self.g_max
        b = self.b, self.b_max
        y = self.y, self.y_max
        x = self.x, self.x_max
        m = self.m, self.m_max
        h = self.h, self.h_max
        c = self.c, self.c_max
        return self.__class__(self.name, health, r, g, b, y, x, m, h, c)
881909
def set_weights(self, weights_values: dict, ignore_missing=False):
        
        network_name = self.__class__.__name__.lower()

        with tf.variable_scope(network_name):
            for layer_name in weights_values:
                with tf.variable_scope(layer_name, reuse=True):
                    for param_name, data in weights_values[layer_name].items():
                        try:
                            var = tf.get_variable(param_name)
                            self._session.run(var.assign(data))

                        except ValueError:
                            if not ignore_missing:
                                raise
1044567
def _copy_net(block_out, net, temp_wv_net, mem_map):
    
    new_args = tuple(temp_wv_net[a_arg] for a_arg in net.args)
    new_dests = tuple(temp_wv_net[a_dest] for a_dest in net.dests)
    if net.op in "m@":  # special stuff for copying memories
        new_param = _get_new_block_mem_instance(net.op_param, mem_map, block_out)
    else:
        new_param = net.op_param

    new_net = LogicNet(net.op, new_param, args=new_args, dests=new_dests)
    block_out.add_net(new_net)
773930
def run_rnaseq_ann_filter(data):
    
    data = to_single_data(data)
    if dd.get_vrn_file(data):
        eff_file = effects.add_to_vcf(dd.get_vrn_file(data), data)[0]
        if eff_file:
            data = dd.set_vrn_file(data, eff_file)
        ann_file = population.run_vcfanno(dd.get_vrn_file(data), data)
        if ann_file:
            data = dd.set_vrn_file(data, ann_file)
    variantcaller = dd.get_variantcaller(data)
    if variantcaller and ("gatk-haplotype" in variantcaller):
        filter_file = variation.gatk_filter_rnaseq(dd.get_vrn_file(data), data)
        data = dd.set_vrn_file(data, filter_file)
    # remove variants close to splice junctions
    vrn_file = dd.get_vrn_file(data)
    vrn_file = variation.filter_junction_variants(vrn_file, data)
    data = dd.set_vrn_file(data, vrn_file)
    return [[data]]