<jupyter_start><jupyter_text>NOTE: Run extract PhyloWGS results script first.<jupyter_code>output_path = "/Users/seonghwanjun/ScRNACloneEvaluation/data/simul/binary/snvs/"
data_path = "/Users/seonghwanjun/data/simul/binary/"
df = ProcessPhyloWGSOutput(data_path, 0, output_path)
output_path = "/Users/seonghwanjun/ScRNACloneEvaluation/data/simul/quadternary_multiregion/snvs/"
data_path = "/Users/seonghwanjun/data/simul/quadternary_multiregion/"
df = ProcessPhyloWGSOutput(data_path, 0, output_path)
# Compute the metrics on PhyloWGS.
def ProcessCanopyOutput(data_path, case_no, output_path = None, rep_count = 20):
    rand = []
    mutual_info = []
    vmeasure = []
    ancestral_metric = []
    for rep in range(rep_count):
        rep_path = os.path.join(data_path, "rep" + str(rep))
        case_path = os.path.join(rep_path, "case" + str(case_no))
        clustering_file = os.path.join(case_path, "canopy", "predicted.csv")
        ancestral_matrix_file = os.path.join(case_path, "canopy", "ancestral_matrix.csv")
        if os.path.exists(clustering_file) and os.path.exists(ancestral_matrix_file):
            truth0 = pd.read_csv(os.path.join(case_path, "cluster_labels.txt"), header=None, names=["ID", "Cluster"])
            ancestral_matrix_truth = np.asarray(pd.read_csv(os.path.join(case_path, "ancestral_matrix.csv"), header=None))

            predicted = pd.read_csv(clustering_file)
            ancestral_matrix = np.asarray(pd.read_table(ancestral_matrix_file, header=None, sep=" "))

            rand.append(adjusted_rand_score(truth0["Cluster"], predicted["Cluster"]))
            mutual_info.append(adjusted_mutual_info_score(truth0["Cluster"], predicted["Cluster"]))
            vmeasure.append(v_measure_score(truth0["Cluster"], predicted["Cluster"]))
            ancestral_metric.append(np.mean(np.abs(ancestral_matrix_truth - ancestral_matrix)))

    df = pd.DataFrame(list(zip(rand, mutual_info, vmeasure, ancestral_metric)), columns=["AdjRandIndex", "AdjMutualInformation", "VMeasure", "AncestralMetric"])
    if output_path is not None:
        if not os.path.exists(output_path):
            os.makedirs(output_path)
        output_file = os.path.join(output_path, "canopy.csv")
        df.to_csv(output_file, index=False)
    return df

output_path = "/Users/seonghwanjun/ScRNACloneEvaluation/data/simul/binary/snvs/"
data_path = "/Users/seonghwanjun/data/simul/binary/"
df = ProcessCanopyOutput(data_path, 0, output_path)
output_path = "/Users/seonghwanjun/ScRNACloneEvaluation/data/simul/binary_cn/snvs/"
data_path = "/Users/seonghwanjun/data/simul/binary_cn/"
df = ProcessCanopyOutput(data_path, 0, output_path)
output_path = "/Users/seonghwanjun/ScRNACloneEvaluation/data/simul/quadternary_cn/snvs/"
data_path = "/Users/seonghwanjun/data/simul/quadternary_cn/"
df = ProcessCanopyOutput(data_path, 0, output_path)
output_path = "/Users/seonghwanjun/ScRNACloneEvaluation/data/simul/quadternary_cn_multiregion/snvs/"
data_path = "/Users/seonghwanjun/data/simul/quadternary_cn_multiregion//"
df = ProcessCanopyOutput(data_path, 0, output_path)
output_path = "/Users/seonghwanjun/ScRNACloneEvaluation/data/simul/quadternary_multiregion/snvs/"
data_path = "/Users/seonghwanjun/data/simul/quadternary_multiregion/"
df = ProcessCanopyOutput(data_path, 0, output_path)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12804328223624886, 'fraction_numerical': 0.003907424105801022, 'mean_word_length': 5.084095063985375, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '409387', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1179, 'n_words': 151, 'path': 'scripts/misc/simul/ComparisonToBulkDeconvolutionMethods.ipynb', 'repo_name': 'junseonghwan/PhylExAnalysis', 'size': '3327'}