<commit_before>#!/usr/bin/env python
# coding: utf-8

import scanpy as sc
import scIB
import warnings
warnings.filterwarnings('ignore')

if __name__=='__main__':
    """
    read adata object, compute all metrics and output csv.
    """
    
    import argparse
    import os

    parser = argparse.ArgumentParser(description='Compute all metrics')

    parser.add_argument('-a', '--uncorrected', required=True)
    parser.add_argument('-i', '--integrated', required=True)
    parser.add_argument('-o', '--output', required=True, help='output directory')
    parser.add_argument('-b', '--batch_key', required=True, help='Key of batch')
    parser.add_argument('-l', '--label_key', required=True, help='Key of annotated labels e.g. "cell_type"')
    parser.add_argument('-t', '--type', required=True, help='Type of result: full, embed, knn\n full: scnaorama, seurat, MNN\n embed: scanorama, Harmony\n knn: BBKNN')
    parser.add_argument('-c', '--cluster_key', default='louvain', help='Name of cluster key, use it for new clustering if key is not present')
    parser.add_argument('-s', '--s_phase', default=None, help='S-phase marker genes')
    parser.add_argument('-g', '--g2m_phase', default=None, help='G2-/M-phase marker genes')
    parser.add_argument('-v', '--hvgs', default=None, help='Number of highly variable genes', type=int)
    args = parser.parse_args()
    
    result_types = [
        "full", # reconstructed expression data
        "embed", # embedded/latent space
        "knn" # only corrected neighbourhood graph as output
    ]
    if args.type not in result_types:
        raise ValueError(f'{args.type} is not a valid result type flag')
    
    batch_key = args.batch_key
    label_key = args.label_key
    cluster_key = args.cluster_key
    cc = (args.s_phase is not None) and (args.g2m_phase is not None)
    hvg = args.hvgs is not None
    
    base = os.path.basename(args.integrated)
    out_prefix = f'{os.path.splitext(base)[0]}_{args.type}'

    ###
    
    print("reading adata before integration")
    adata = sc.read(args.uncorrected, cache=True)
    print(adata)
    if (adata.n_vars < args.hvgs) and (args.hvgs is not None):
        raise ValueError("There are less genes in the uncorrected adata than specified for HVG selection")

    print("reading adata after integration")<commit_msg>Change line 53 about args.hvgs is not None<commit_after>#!/usr/bin/env python
# coding: utf-8

import scanpy as sc
import scIB
import warnings
warnings.filterwarnings('ignore')

if __name__=='__main__':
    """
    read adata object, compute all metrics and output csv.
    """
    
    import argparse
    import os

    parser = argparse.ArgumentParser(description='Compute all metrics')

    parser.add_argument('-a', '--uncorrected', required=True)
    parser.add_argument('-i', '--integrated', required=True)
    parser.add_argument('-o', '--output', required=True, help='output directory')
    parser.add_argument('-b', '--batch_key', required=True, help='Key of batch')
    parser.add_argument('-l', '--label_key', required=True, help='Key of annotated labels e.g. "cell_type"')
    parser.add_argument('-t', '--type', required=True, help='Type of result: full, embed, knn\n full: scnaorama, seurat, MNN\n embed: scanorama, Harmony\n knn: BBKNN')
    parser.add_argument('-c', '--cluster_key', default='louvain', help='Name of cluster key, use it for new clustering if key is not present')
    parser.add_argument('-s', '--s_phase', default=None, help='S-phase marker genes')
    parser.add_argument('-g', '--g2m_phase', default=None, help='G2-/M-phase marker genes')
    parser.add_argument('-v', '--hvgs', default=None, help='Number of highly variable genes', type=int)
    args = parser.parse_args()
    
    result_types = [
        "full", # reconstructed expression data
        "embed", # embedded/latent space
        "knn" # only corrected neighbourhood graph as output
    ]
    if args.type not in result_types:
        raise ValueError(f'{args.type} is not a valid result type flag')
    
    batch_key = args.batch_key
    label_key = args.label_key
    cluster_key = args.cluster_key
    cc = (args.s_phase is not None) and (args.g2m_phase is not None)
    hvg = args.hvgs is not None
    
    base = os.path.basename(args.integrated)
    out_prefix = f'{os.path.splitext(base)[0]}_{args.type}'

    ###
    
    print("reading adata before integration")
    adata = sc.read(args.uncorrected, cache=True)
    print(adata)
    if (args.hvgs is not None):
        if (adata.n_vars < args.hvgs):
            raise ValueError("There are less genes in the uncorrected adata than specified for HVG selection")

    print("reading adata after integration")
{'fraction_non_alphanumeric': 0.13619919131730154, 'fraction_numerical': 0.002553734837199404, 'mean_word_length': 3.56754130223518, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '188350', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1495, 'n_words': 414}