<jupyter_start><jupyter_text>Table of ContentsDependenciesFunctionsPathsMainCBTTC  Dependencies<jupyter_code>library(tidyr)<jupyter_output><empty_output><jupyter_text>Functions<jupyter_code>matchexp_matrixfx <- function(exp_matrix, estimate_manifest, group, sample_type, matchingcol){
    
    message("dimensions of exp_matrix: ", deparse(substitute(exp_matrix)))
    print(dim(exp_matrix))
    
    subset_estimate_manifest <- estimate_manifest[estimate_manifest$group == group,]
    subset_estimate_manifest_sampletype <- subset_estimate_manifest[grepl(sample_type,
                                                                    subset_estimate_manifest$sample_type),]
    
    message("dimensions of estimate_manifest_df for: ", group, " sample_type:", sample_type)
    print(dim(subset_estimate_manifest_sampletype))
    
    exp_matrix_matchingset <- exp_matrix[,colnames(exp_matrix) %in% 
                                         subset_estimate_manifest_sampletype[[matchingcol]]]
    
    message("dimensions of exp_matrix_matchingset for: ", deparse(substitute(exp_matrix)), 
            " with matching column: ", matchingcol)
    print(dim(exp_matrix_matchingset))
    
    exp_matrix_matchingset <- cbind(exp_matrix[,1:2], exp_matrix_matchingset)

    return(exp_matrix_matchingset)
}
longtowidefx <- function(long_exp_matrix){ 
    wide_exp_matrix <- spread(long_exp_matrix, key = "sample", value = "tpm")
    return(wide_exp_matrix)
}<jupyter_output><empty_output><jupyter_text>Paths<jupyter_code>manifestpath <- "/Users/anabbi/OneDrive - UHN/Documents/IPD2/Manifests/"
datapath <- "/Users/anabbi/OneDrive - UHN/Documents/IPD2/Data/"
plotpath <- "/Users/anabbi/OneDrive - UHN/Documents/IPD2/Plots/"<jupyter_output><empty_output><jupyter_text>Main  CBTTC From Cavatica<jupyter_code>CBTTCtpm <- read.table(paste0(datapath, "exp_mat/KF_CBTTC_tpm_rsem_matrix.txt_sampleid.txt"), sep = "\t",
                    header = TRUE, stringsAsFactors = FALSE, check.names = F)
head(CBTTCtpm)
CBTTCtpm <- cbind(NA, NA, CBTTCtpm)
colnames(CBTTCtpm)[1:2] <- c("ensembl_id", "hgnc_symbol")
CBTTCtpm$hgnc_symbol <- gsub(".*_", "", CBTTCtpm$`Var.3`)
CBTTCtpm$ensembl_id <- gsub("_.*", "", CBTTCtpm$`Var.3`)
CBTTCtpm$`Var.3` <- NULL
dim(CBTTCtpm)
CBTTCtpm <- CBTTCtpm[!duplicated(CBTTCtpm$hgnc_symbol),]
dim(CBTTCtpm)
head(CBTTCtpm)
CBTTCtpm[ CBTTCtpm$hgnc_symbol == "DAZ1", "7316-905"]
write.table(CBTTCtpm,
            file = paste0(datapath, "exp_mat/CBTTC_tpm_matrix_dedup.txt"),
                sep = "\t", quote = F, row.names = F)
write.table(CBTTCtpm[,colnames(CBTTCtpm) !="ensembl_id"],
            file = paste0(datapath, "exp_mat/CBTTC_tpm_matrix_dedup_hgnc.txt"),
                sep = "\t", quote = F, row.names = F)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12934782608695652, 'fraction_numerical': 0.007608695652173913, 'mean_word_length': 4.35077519379845, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '590894', 'license': 'Apache-2.0', 'n_tokens_mistral': 1071, 'n_tokens_neox': 987, 'n_words': 123, 'path': 'notebooks/03_exp_matrix_4ESTIMATE.ipynb', 'repo_name': 'pughlab/immunogenomics_pedNST', 'size': '2760'}