<commit_before>"""
(C) <NAME> 2016
PanCancer NF1 Classifier
scripts/util/get_y_class.py

Description:
Function to determine nearest neighbor of unlabeled data

Usage:
Import only by build_y.py
"""

import os
import pandas as pd


def get_y_class(mut, tis, gene=['NF1'], mut_filt=['Silent'],
                x_base='data/X/normalized/'):
    """
    Output classification for samples in X

    Arguments:
    :param mut: pandas dataframe with mutation info
    :param tis: the tissue to load X
    :param gene: string indicating gene in mutation dataframe
    :param mut_filt: list of classes of mutations to filter
    :param x_base: string of where the X matrices are stored

    Output:
    list of classifications for each sample
    0 - Not mutated
    1 - Mutated
    2 - Not assessed
    list of samples belonging to each assignment
    """
    # Read in X
    x_files = os.listdir(x_base)
    x_file = [x for x in x_files if x.split('_')[0] == tis]
    X = pd.read_csv(x_base + x_file[0], delimiter='\t', index_col=0)

    y_class = []
    zero_samp = []
    one_samp = []
    two_samp = []
    for samp in X.columns:
        # Subset mutation file to only consider that sample
        m = mut[mut['#sample'] == samp]

        # If the sample is not in the mutation file
        if m.shape[0] == 0:
            y_class.append(0)
            two_samp.append(samp)

        # If the sample is in the mutation file<commit_msg>removing mutable function arg defaults<commit_after>"""
(C) <NAME> 2016
PanCancer NF1 Classifier
scripts/util/get_y_class.py

Description:
Function to return Y matrix as well as different classes of samples that
indicate if the sample is mutated, not mutated, or not assayed.

Usage:
Import only by build_y.py
"""

import os
import pandas as pd


def get_y_class(mut, tis, gene, mut_filt, x_base='data/X/normalized/'):
    """
    Output classification for samples in X

    Arguments:
    :param mut: pandas dataframe with mutation info
    :param tis: the tissue to load X
    :param gene: list of genes in mutation dataframe
    :param mut_filt: list of classes of mutations to filter
    :param x_base: string of where the X matrices are stored

    Output:
    list of classifications for each sample
    0 - Not mutated
    1 - Mutated
    2 - Not assessed
    list of samples belonging to each assignment
    """
    # Read in X
    x_files = os.listdir(x_base)
    x_file = [x for x in x_files if x.split('_')[0] == tis]
    X = pd.read_csv(x_base + x_file[0], delimiter='\t', index_col=0)

    y_class = []
    zero_samp = []
    one_samp = []
    two_samp = []
    for samp in X.columns:
        # Subset mutation file to only consider that sample
        m = mut[mut['#sample'] == samp]

        # If the sample is not in the mutation file
        if m.shape[0] == 0:
            y_class.append(0)
            two_samp.append(samp)

        # If the sample is in the mutation file
{'fraction_non_alphanumeric': 0.08866826429305033, 'fraction_numerical': 0.009928106812735364, 'mean_word_length': 2.6893939393939394, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2822938', 'n_tokens_mistral': 971, 'n_tokens_neox': 916, 'n_words': 347}