示例#1
0
def get_isabl_scrna_analyses(type):
    latest_scrna_rdata = []
    all_analyses = ii.get_instances(
        'analyses',
        application__name__in=
        'CELLASSIGN Individual Application, CELLASSIGN Project Application')

    if type == "cohort":
        cohort_analyses = [
            analysis for analysis in all_analyses
            if is_cohort_analysis(analysis)
        ]

        cohort_analyses = [{
            **_process_analysis(analysis), "dashboard_id":
            "cohort_all"
        } for analysis in cohort_analyses]

        return cohort_analyses

    else:  # is patient
        analyses = [{
            **_process_analysis(analysis), "dashboard_id":
            analysis["individual_level_analysis"]["identifier"]
        } for analysis in all_analyses if is_patient_analysis(analysis)]

    return analyses
示例#2
0
def get_scgenome_isabl_data(target_aliquot):

    APP_VERSION = '1.0.0'
    os.environ["ISABL_API_URL"] = 'https://isabl.shahlab.mskcc.org/api/v1/'
    os.environ['ISABL_CLIENT_ID'] = '1'
    VERSION = "0.0.1"

    experiment = ii.get_instances("experiments", aliquot_id=target_aliquot)[0]

    alignment = get_analyses('SCDNA-ALIGNMENT', VERSION, experiment.system_id)
    hmmcopy = get_analyses('SCDNA-HMMCOPY', VERSION, experiment.system_id)
    annotation = get_analyses('SCDNA-ANNOTATION', VERSION,
                              experiment.system_id)

    #current = [alignment.pk, hmmcopy.pk, annotation.pk]

    #retrieve paths
    annotation_metrics = get_annotation_path(annotation.pk)
    hmmcopy_metrics, hmmcopy_reads, hmmcopy_segs = get_hmmcopy_path(hmmcopy.pk)
    alignment_metrics, gc_metrics = get_alignment_path(alignment.pk)

    results = get_qc_data_from_filenames([annotation_metrics], [hmmcopy_reads],
                                         [hmmcopy_segs], [hmmcopy_metrics],
                                         [alignment_metrics], [gc_metrics])

    hmmcopy_data = collections.defaultdict(list)

    for table_name, data in results.items():
        hmmcopy_data[table_name].append(data)
    for table_name in hmmcopy_data:
        hmmcopy_data[table_name] = pd.concat(hmmcopy_data[table_name],
                                             ignore_index=True)

    return hmmcopy_data
示例#3
0
def get_analyses(app, version, exp_system_id):

    analyses = ii.get_instances('analyses',
                                application__name=app,
                                application__version=version,
                                targets__system_id=exp_system_id)
    assert len(analyses) == 1
    return analyses[0]
示例#4
0
def get_scgenome_isabl_annotation_pk(target_aliquot):
    APP_VERSION = '1.0.0'
    os.environ["ISABL_API_URL"] = 'https://isabl.shahlab.mskcc.org/api/v1/'
    os.environ['ISABL_CLIENT_ID'] = '1'
    VERSION = "0.0.1"

    experiment = ii.get_instances("experiments", aliquot_id=target_aliquot)[0]

    alignment = get_analyses('SCDNA-ALIGNMENT', VERSION, experiment.system_id)
    return alignment.pk
示例#5
0
def list_projects():
    """
    List projects currently in Isabl
    """
    projects = ii.get_instances('projects')

    data = []
    for project in projects:
        data.append({'project_title': project.title})

    df = pd.DataFrame(data).sort_values(by=['project_title'], ascending=True)
    for index, row in df.iterrows():
        print(row['project_title'])
示例#6
0
def list_apps():
    """
    List apps currently in Isabl
    """
    apps = ii.get_instances('applications')

    data = []
    for app in apps:
        data.append({'app_name': app.name})

    df = pd.DataFrame(data).sort_values(by=['app_name'],
                                        ascending=True).drop_duplicates()
    for index, row in df.iterrows():
        print(row['app_name'])
示例#7
0
def get_data(apps, project):
    """
    Retrieve analyses paths from Isabl.
    """

    analyses = ii.get_instances('analyses',
                                application__name__in=apps,
                                projects__title__in=project)

    data = get_parent_paths(analyses)

    return pd.DataFrame(data)[[
        "individual", "app", "target_sample_category", "target_sample", "path"
    ]]
示例#8
0
def get_paths(apps, projects, details):
    """
    Retrieve analyses paths from Isabl.
    """
    # apps = apps.replace(' ', '')
    # projects = projects.replace(' ', '')

    analyses = ii.get_instances('analyses',
                                application__name__in=apps,
                                projects__title__in=projects)

    if details:
        data = get_detailed_paths(analyses)
    else:
        data = get_parent_paths(analyses)

    df = pd.DataFrame(data)
    df.to_csv(f'./isabl_paths_{time.strftime("%Y%m%d-%H%M%S")}.csv',
              index=False)