Code Paper for Benchmarking Project

Hi! This is a very informally written document just to give the beats of what is happening in the code, and the analysis I am doing. It needs to be MUCH more formalized before being shown publicly, but it is useful for understanding!

Preprocessing

All data is in disparate forms. So, I standardized it so that it can be easily utilized in the downstream without having to continuously redo work. I chose to standardize the notation to the Conumee notations, using

  • chrom for chromosomes.

  • loc.start for when the location of a segment starts.

  • loc.end for when the location of a segment ends.

  • seg.mean for the log2-ratio.

  • CNVStatus for whether a block represents a deletion, amplification & normal segments.

  • type is a representative factor to say what method gave that segment, because we compose a database for each case, and we need to distinguish the segments from each other.

  • we also add an extra factor named “Gene” to label relevant segments which have a gene inside it.

Attached are the pre-processing blocks.

LMS Processing

labLMSProc <- function(STTq, Technology, binSize) {

    # Correlate by STT information between methylation
    # Sentrix and SNP data.
    correlationSheet <- read.csv("~/Work/Analysis/LabData/LMS_SNP_EPIC_array_data/correlative.csv") %>%
        filter(STT == STTq)

    cnvMatch <- read_delim(paste0("~/Work/Analysis/LabData/LMS_SNP_EPIC_array_data/ChAS/ChAS_data_01Feb2026/ChAS_LMS_Probe_and_segment_level_data_01Feb2026/STT",
        STTq, "_Recentered_Segment_level_data_01Feb2026.segment.txt"))

    # methylMatch <-
    # read.csv(paste0('~/Work/Analysis/Outputs/MethylMaster/LabLMS/',
    # paste0(correlationSheet$Sentrix_ID[1],'_',
    # correlationSheet$Sentrix_Position[1], '/'),
    # 'autocorrected_regions.csv'))

    conumeeMatch <- read.csv(paste0("~/Work/Analysis/Outputs/Conumee/LabLMS/",
        binSize, "/", paste0(correlationSheet$Sentrix_ID[1],
            "_", correlationSheet$Sentrix_Position[1], ".csv")))

    sesameMatch <- read.csv(paste0("~/Work/Analysis/Outputs/SeSAMe/LabLMS/",
        binSize, "/", paste0("segments_", correlationSheet$Sentrix_ID[1],
            "_", correlationSheet$Sentrix_Position[1], ".csv")))

    methylMatch <- read.csv(paste0("~/Work/Analysis/Outputs/MethylMaster/LabLMS/",
        binSize, "/", correlationSheet$Sentrix_ID[1], "_", correlationSheet$Sentrix_Position[1],
        "/autocorrected_regions.csv"))

    cnvMatch <- cnvMatch %>%
        dplyr::filter(!(Type == "LOH")) %>%
        dplyr::filter(Chromosome != 24 & Chromosome != 25) %>%
        dplyr::select("Chromosome", "StartPosition", "StopPosition",
            "Median Log2 Ratio") %>%
        dplyr::rename(chrom = "Chromosome", loc.start = "StartPosition",
            loc.end = "StopPosition", seg.mean = "Median Log2 Ratio") %>%
        dplyr::mutate(seg.mean = as.numeric(seg.mean)) %>%
        dplyr::mutate(CNVStatus = case_when(seg.mean <= -0.2 ~
            "Deletion", seg.mean >= 0.2 ~ "Amplification", TRUE ~
            "Normal"), type = "SNP")

    if (Technology == "MethylMaster") {
        methylMatch <- methylMatch %>%
            dplyr::rename(seg.mean = "Mean", loc.start = "bp.Start",
                loc.end = "bp.End") %>%
            dplyr::select(seg.mean, loc.start, loc.end, Chromosome) %>%
            mutate(type = "MethylMaster") %>%
            dplyr::rename(chrom = "Chromosome") %>%
            dplyr::mutate(chrom = as.numeric(gsub("chr", "",
                chrom))) %>%
            filter(!is.na(chrom)) %>%
            dplyr::mutate(loc.start = as.numeric(loc.start),
                loc.end = as.numeric(loc.end), seg.mean = as.numeric(seg.mean)) %>%
            mutate(CNVStatus = case_when(seg.mean <= -0.2 ~ "Deletion",
                seg.mean >= 0.2 ~ "Amplification", TRUE ~ "Normal"))
        combinedSet <- rbind(methylMatch, cnvMatch) %>%
            mutate(Gene = as.character(0)) %>%
            arrange(chrom)
    }

    if (Technology == "Conumee") {
        conumeeMatch <- conumeeMatch %>%
            dplyr::select(chrom, loc.start, loc.end, seg.mean) %>%
            mutate(CNVStatus = case_when(seg.mean <= -0.2 ~ "Deletion",
                seg.mean >= 0.2 ~ "Amplification", TRUE ~ "Normal")) %>%
            mutate(chrom = as.numeric(gsub("chr", "", chrom))) %>%
            mutate(type = "Conumee")
        combinedSet <- rbind(conumeeMatch, cnvMatch) %>%
            mutate(Gene = as.character(0)) %>%
            arrange(chrom)
    }

    if (Technology == "Sesame") {
        sesameMatch <- sesameMatch %>%
            dplyr::select(c("chrom", "loc.start", "loc.end",
                "seg.mean")) %>%
            dplyr::mutate(chrom = str_remove_all(chrom, "chr")) %>%
            filter(!(chrom == "X") & !(chrom == "Y")) %>%
            mutate(chrom = as.numeric(chrom)) %>%
            arrange(chrom) %>%
            mutate(CNVStatus = case_when(seg.mean > 0.3 ~ "Amplification",
                seg.mean < -0.3 ~ "Deletion", TRUE ~ "Normal"),
                type = "SeSAMe")
        combinedSet <- rbind(sesameMatch, cnvMatch) %>%
            mutate(Gene = as.character(0), seg.mean = as.numeric(seg.mean)) %>%
            arrange(chrom)
    }
    combinedSet
}

It utilizes an unique identifier (STT) to retrieve relevant datasets from inside the files and processes them into the correct format. It then returns the whole dataset.

LM Processing

LMStt <- function(STT, bin) {

    corrSheet <- read.csv("~/Work/Analysis/LabData/LM_SNP_EPIC_array_data/EPIC_array_data_LM/idat_files/SampSheet.csv") %>%
        dplyr::filter(STT == STT)
    sentrixID <- corrSheet$Sentrix_ID[1]
    sentrixPos <- corrSheet$Sentrix_Position[1]

    SNP <- read_delim(paste0("~/Work/Analysis/LabData/LM_SNP_EPIC_array_data/ChAS/ChAS_data_01Feb2026/ChAS_LM_Probe_and_segment_level_data_01Feb2026/STT",
        STT, "_Segment_level_data_01Feb2026.segment.txt"))
    SNP <- SNP %>%
        dplyr::filter(!(Type == "LOH")) %>%
        dplyr::filter(Chromosome != 24 & Chromosome != 25) %>%
        dplyr::select("Chromosome", "StartPosition", "StopPosition",
            "Median Log2 Ratio") %>%
        dplyr::rename(chrom = "Chromosome", loc.start = "StartPosition",
            loc.end = "StopPosition", seg.mean = "Median Log2 Ratio") %>%
        dplyr::mutate(seg.mean = as.numeric(seg.mean)) %>%
        dplyr::mutate(CNVStatus = case_when(seg.mean <= -0.2 ~
            "Deletion", seg.mean >= 0.2 ~ "Amplification", TRUE ~
            "Normal"), type = "SNP")

    # MethylMasteR
    outputDirMethyl <- paste0("~/Work/Analysis/Outputs/MethylMaster/LM/",
        bin, "/", sentrixID, "_", sentrixPos, "/autocorrected_regions.csv")
    cnvMethyl <- read.csv(outputDirMethyl) %>%
        dplyr::select(c("Chromosome", "bp.Start", "bp.End", "Mean")) %>%
        dplyr::rename(chrom = "Chromosome", loc.start = "bp.Start",
            loc.end = "bp.End", seg.mean = "Mean") %>%
        dplyr::mutate(CNVStatus = case_when(seg.mean > 0.3 ~
            "Amplification", seg.mean < -0.3 ~ "Deletion", TRUE ~
            "Normal"), type = "MethylMaster")
    cnvMethyl$chrom <- as.numeric(str_remove_all(cnvMethyl$chrom,
        pattern = "chr"))
    cnvMethyl <- cnvMethyl %>%
        filter(!(is.na(chrom))) %>%
        arrange(chrom)

    # SeSAMe
    outputDirSesame <- paste0("~/Work/Analysis/Outputs/SeSAMe/LM/bins/",
        bin, "/", "segments_", sentrixID, "_", sentrixPos, ".csv")
    sesameOutput <- read.csv(outputDirSesame) %>%
        dplyr::select(c("chrom", "loc.start", "loc.end", "seg.mean")) %>%
        dplyr::mutate(chrom = str_remove_all(chrom, "chr")) %>%
        filter(!(chrom == "X") & !(chrom == "Y")) %>%
        mutate(chrom = as.numeric(chrom)) %>%
        arrange(chrom) %>%
        mutate(CNVStatus = case_when(seg.mean > 0.3 ~ "Amplification",
            seg.mean < -0.3 ~ "Deletion", TRUE ~ "Normal"), type = "SeSAMe")

    # Conumee
    outputDirConumee <- paste0("~/Work/Analysis/Outputs/Conumee/LMData/bins/",
        bin, "/", sentrixID, "_", sentrixPos, ".csv")
    case <- read.csv(outputDirConumee)
    case <- case %>%
        dplyr::select(-c("ID", "bstat")) %>%
        mutate(CNVStatus = case_when(case$seg.mean > 0.2 ~ "Amplification",
            case$seg.mean < -0.2 ~ "Deletion", TRUE ~ "Normal"),
            chrom = as.numeric(str_remove_all(chrom, "chr"))) %>%
        dplyr::arrange(chrom) %>%
        mutate(type = "Conumee") %>%
        dplyr::select(-c("num.mark", "pval", "seg.median", "X"))

    rbind(SNP, case, sesameOutput, cnvMethyl)

}

This does basically the same thing, except for leiomyoma samples instead of leiomyosarcoma samples. It then returns the relevant dataset. The Gene factor is dropped because it is not evaluated for Leiomyoma.

Normal Processing

labNmrlProc <- function(Sentrix, Technology, binSize) {
    # Correlate by STT information between methylation
    # Sentrix and SNP data.
    correlationSheet <- read.csv("~/Work/Analysis/LabData/Normal_smooth_muscle_EPIC_data/idat_files/Sample_Sheet_Normal.csv") %>%
        filter(Basename == Sentrix)

    conumeeMatch <- read.csv(paste0("~/Work/Analysis/Outputs/Conumee/LabNormals/",
        binSize, "/", paste0(Sentrix, ".csv")))

    sesameMatch <- read.csv(paste0("~/Work/Analysis/Outputs/SeSAMe/Normals/",
        binSize, "/", paste0("segments_", Sentrix, ".csv")))

    if (Technology == "MethylMaster") {
        methylMatch <- methylMatch %>%
            dplyr::rename(seg.mean = "Mean", loc.start = "bp.Start",
                loc.end = "bp.End") %>%
            dplyr::select(seg.mean, loc.start, loc.end, Chromosome) %>%
            mutate(type = "MethylMaster") %>%
            dplyr::rename(chrom = "Chromosome") %>%
            dplyr::mutate(chrom = as.numeric(gsub("chr", "",
                chrom))) %>%
            filter(!is.na(chrom)) %>%
            dplyr::mutate(loc.start = as.numeric(loc.start),
                loc.end = as.numeric(loc.end), seg.mean = as.numeric(seg.mean)) %>%
            mutate(CNVStatus = case_when(seg.mean <= -0.2 ~ "Deletion",
                seg.mean >= 0.2 ~ "Amplification", TRUE ~ "Normal"))
        combinedSet <- methylMatch %>%
            arrange(chrom)
    }

    if (Technology == "Conumee") {
        conumeeMatch <- conumeeMatch %>%
            dplyr::select(chrom, loc.start, loc.end, seg.mean) %>%
            mutate(CNVStatus = case_when(seg.mean <= -0.2 ~ "Deletion",
                seg.mean >= 0.2 ~ "Amplification", TRUE ~ "Normal")) %>%
            mutate(chrom = as.numeric(gsub("chr", "", chrom))) %>%
            mutate(type = "Conumee")
        combinedSet <- conumeeMatch %>%
            arrange(chrom)
    }

    if (Technology == "Sesame") {
        sesameMatch <- sesameMatch %>%
            dplyr::select(c("chrom", "loc.start", "loc.end",
                "seg.mean")) %>%
            dplyr::mutate(chrom = str_remove_all(chrom, "chr")) %>%
            filter(!(chrom == "X") & !(chrom == "Y")) %>%
            mutate(chrom = as.numeric(chrom)) %>%
            arrange(chrom) %>%
            mutate(CNVStatus = case_when(seg.mean > 0.3 ~ "Amplification",
                seg.mean < -0.3 ~ "Deletion", TRUE ~ "Normal"),
                type = "SeSAMe")
        combinedSet <- sesameMatch %>%
            arrange(chrom)
    }

    combinedSet
}

This is the final processing function to process out the normals, contributing to the genome-wide log2-ratio.

Analysis

We now move onto the actual meat of the analytic code. This will be split into statistics generation & visualization.

Basic Metrics

Bin size vs. accuracy – normal tissue 

This was done to evaluate whether the tissues that were being used for normalization were actually normal. The code has been annotated with comments below to gain full understanding of the system.

This entire evaluation is contained in a function, which asks for a set of IDs (essentially the IDs of the normals, and the bin that we want to evaluate the statistics for.

caseCorr <- function(IDs, bin) {

    Methyl <- c()
    Ses <- c()
    Con <- c()

    for (ID in IDs) {
        MethylMaster <- read.csv(paste0("~/Outputs/MethylMaster/Normals/",
            bin, "/", ID, "/autocorrected_regions.csv"))
        MethylMaster <- median(MethylMaster$Mean)
        Sesame <- read.csv(paste0("~/Outputs/SeSAMe/Normals/",
            bin, "/segments_", ID, ".csv"))
        Sesame <- median(Sesame$seg.mean)
        Conumee <- read.csv(paste0("~/Outputs/Conumee/LabNormals/",
            bin, "/", ID, ".csv"))
        Conumee <- median(Conumee$seg.mean)

        Methyl <- c(Methyl, MethylMaster)
        Ses <- c(Ses, Sesame)
        Con <- c(Con, Conumee)

    }

    acc <- data.frame(Conumee_Median = median(Con), Conumee_SD = sd(Con),
        Sesame_Median = median(Ses), Sesame_SD = sd(Ses), Methyl_Median = median(Methyl),
        Methyl_SD = sd(Methyl))
    acc

}

It then takes the median log2 ratio of each sample for each software and bin, and returns it as a list, given by the initialized Methyl (MethylMasteR), Ses (SeSAMe) and Con (Conumee) values.

It then returns a data frame for easy post-processing.

To add it to the word document, I just read it off the terminal, but I could also create a dataframe for this purpose quite quickly. The driver code just involves querying the samples across the 3 bin sizes being studied.

Genomic Index for LMS

GenomicIndex <- function(dfCH3, sw) {
    if (sw == F) {
        dfSNP <- dfCH3 %>%
            dplyr::filter(type == "SNP") %>%
            dplyr::filter(CNVStatus != "Normal")
        modChrom <- length(unique(dfSNP$chrom))
        CNVCount <- nrow(dfSNP)
        ret <- (CNVCount^2)/modChrom
        return(ret)
    } else {

        # Filter out for clinically significant segments
        # %>% filter(CNVStatus != Normal)
        dfCH3f <- dfCH3 %>%
            dplyr::filter(type == "Conumee" | type == "MethylMaster" |
                type == "SeSAMe") %>%
            dplyr::filter(CNVStatus != "Normal")
        # Count
        CNVCount <- nrow(dfCH3f)
        modChrom <- length(unique(dfCH3f$chrom))

        # Return value
        ret <- (CNVCount^2)/modChrom
        return(ret)
    }
}

This code takes a single dataframe from one of the technologies (as given by the preprocessor above for the LMS), filters it out only for that technology, filters for whether it reflects an CNV, and the counts how many there are, then takes the formula:

\[ GI = \frac{CNV^2}{22} \]

As given. It just then returns that value.

“sw” as an argument in the function is because I wanted to use the function for both SNPs and the methylation CNVs, so it is a convenient way to work with both types without using more if-statements.

Genome Modified

This is a pretty basic metric which works very similarly to the GI calculation above.

GenomeModified <- function(dfCH3) {
    df <- dfCH3 %>%
        dplyr::filter(type != "SNP", CNVStatus != "Normal") %>%
        dplyr::mutate(width = loc.end - loc.start)
    modifiedWidth <- sum(df$width)
    hg19_info <- getChromInfoFromUCSC("hg19") %>%
        dplyr::filter(assembled == "TRUE")
    hg19_info <- hg19_info[1:22, ]
    hg19_total <- sum(hg19_info$size)

    return((modifiedWidth/hg19_total) * 100)

}

It simply queries the information for hg19, filters it to the 22 chromosomes we are studying, sums the whole length, and divided it by the length of modified segments we actually have, and returns a percentage.

The driver code is quite important here however. It calculates the genome changed for each case, then adds it to an array. We can guarantee the order pair because the loop happens in the same order as the dataframe of the SNP data and how the cases are ordered in there.

Then, it prints out by taking a Pearson’s correlation on the different arrays, and in place, makes dataframes containing the percentage of genome changed, so that it can be manually inspected.

stts <- c(9202, 9203, 9327, 9328, 9337, 9338, 9350, 9353, 9354,
    9355, 9356, 9357, 9358)
bins <- c(10000, 50000, 1e+05, 1e+06)
tech <- c("MethylMaster", "Conumee", "Sesame")
genomeCalc <- read_excel("~/Work/Analysis/LabData/LMS_SNP_EPIC_array_data/ChAS/ChAS_data_01Feb2026/design_13LMS_CNVs_other_info_01Feb2026.xlsx") %>%
    dplyr::select("STT", "% Genome Changed") %>%
    dplyr::rename(gc = "% Genome Changed")
bin10kb <- genomeCalc
binDef <- genomeCalc
bin100kb <- genomeCalc
bin1Mb <- genomeCalc

for (bin in bins) {
    print(bin)
    valM <- c()
    valS <- c()
    valC <- c()
    for (stt in stts) {
        valM <- c(valM, GenomeModified(labLMSProc(STTq = stt,
            Technology = "MethylMaster", binSize = bin)))
        valS <- c(valS, GenomeModified(labLMSProc(STTq = stt,
            Technology = "Sesame", binSize = bin)))
        valC <- c(valC, GenomeModified(labLMSProc(STTq = stt,
            Technology = "Conumee", binSize = bin)))
    }
    if (bin == 10000) {
        bin10kb <- data.frame(STT = bin10kb$STT, gc = bin10kb$gc,
            pcentmodM = valM, pcentmodS = valS, pcentmodC = valC)
    }
    if (bin == 50000) {
        binDef <- data.frame(STT = binDef$STT, gc = binDef$gc,
            pcentmodM = valM, pcentmodS = valS, pcentmodC = valC)
    }
    if (bin == 1e+05) {
        bin100kb <- data.frame(STT = bin100kb$STT, gc = bin100kb$gc,
            pcentmodM = valM, pcentmodS = valS, pcentmodC = valC)
    }
    if (bin == 1e+06) {
        bin1Mb <- data.frame(STT = bin1Mb$STT, gc = bin1Mb$gc,
            pcentmodM = valM, pcentmodS = valS, pcentmodC = valC)
    }

    print(paste0("MethylMasteR: ", cor(genomeCalc$gc, valM)))
    print(paste0("SeSAMe: ", cor(genomeCalc$gc, valS)))
    print(paste0("Conumee: ", cor(genomeCalc$gc, valC)))

}
## [1] 10000
## [1] "MethylMasteR: 0.687649075571811"
## [1] "SeSAMe: 0.00278326955354341"
## [1] "Conumee: -0.400415556914374"
## [1] 50000
## [1] "MethylMasteR: 0.755074036591727"
## [1] "SeSAMe: -0.0217828755036478"
## [1] "Conumee: -0.511121929626427"
## [1] 1e+05
## [1] "MethylMasteR: 0.754376210845057"
## [1] "SeSAMe: 0.0390561094591397"
## [1] "Conumee: -0.477686025489507"
## [1] 1e+06
## [1] "MethylMasteR: 0.740706152419858"
## [1] "SeSAMe: 0.0605428007233103"
## [1] "Conumee: -0.443940764266878"

Advanced Metrics

Accuracy Across Bins

fpCheck <- function(df) {
    library(GenomicRanges)
    library(dplyr)
    df <- df %>%
        dplyr::select(-c("Gene"))  # Removes genes, it's unnecessary for this purpose

    pred_df <- df %>%
        filter(!(type == "SNP"))  # The methylation dataset
    pred_df$chrom <- as.character(pred_df$chrom)
    truth_df <- df %>%
        filter(type == "SNP")  # The SNP dataset
    truth_df$chrom <- as.character(truth_df$chrom)

    # Both chromosomes are made into characters because we
    # want to use them as factors ---- Step 1: hg19
    # chromosome sizes (numeric chromosomes 1 to 22) ----
    hg19_info <- getChromInfoFromUCSC("hg19") %>%
        dplyr::filter(assembled == "TRUE")  # Just gets the main dataset from UCSC.
    hg19_info <- hg19_info[1:22, ]  # Only uses the first 22 chromosomes.
    hg19_chr_sizes <- data.frame(Chromosome = as.character(1:22),
        Genome_bp = hg19_info$size)  # Makes them into a referenceable dataframe.

    # ---- Step 2: Convert to GRanges ---- Does what it
    # says on the tin
    truth_gr <- GRanges(seqnames = truth_df$chrom, ranges = IRanges(start = truth_df$loc.start,
        end = truth_df$loc.end), CNV = truth_df$CNVStatus)

    pred_gr <- GRanges(seqnames = pred_df$chrom, ranges = IRanges(start = pred_df$loc.start,
        end = pred_df$loc.end), CNV = pred_df$CNVStatus)

    # ---- Step 3: Overlaps and TP ----
    hits <- findOverlaps(pred_gr, truth_gr)  # Finds the overlaps between the two GRanges

    overlap_ranges <- pintersect(pred_gr[queryHits(hits)], truth_gr[subjectHits(hits)])
    pred_cnv <- mcols(pred_gr)$CNV[queryHits(hits)]  # Returns whether the intersections are deletions, amplifications or normals
    truth_cnv <- mcols(truth_gr)$CNV[subjectHits(hits)]  # Returns whether the intersections are deletions, amplifications or normals

    # The returns are for the corresponding datasets.

    tp_df <- data.frame(Chromosome = as.character(seqnames(overlap_ranges)),
        width = width(overlap_ranges), pred_cnv = pred_cnv, truth_cnv = truth_cnv)  # Creates a dataframe from the given data
    tp_df <- tp_df %>%
        filter(pred_cnv == truth_cnv) %>%
        group_by(Chromosome) %>%
        summarise(TP_bp = sum(width), .groups = "drop")

    # ---- Step 4: False Positives ----
    fp_df <- data.frame(Chromosome = as.character(seqnames(overlap_ranges)),
        width = width(overlap_ranges), pred_cnv = pred_cnv, truth_cnv = truth_cnv) %>%
        filter(pred_cnv != truth_cnv, truth_cnv == "Normal") %>%
        group_by(Chromosome) %>%
        summarise(FP_bp = sum(width), .groups = "drop")  # Calculates the false positives

    # ---- Step 5: False Negatives ----
    fn_df <- data.frame(Chromosome = as.character(seqnames(overlap_ranges)),
        width = width(overlap_ranges), pred_cnv = pred_cnv, truth_cnv = truth_cnv) %>%
        filter(pred_cnv != truth_cnv, pred_cnv == "Normal") %>%
        group_by(Chromosome) %>%
        summarise(FN_bp = sum(width), .groups = "drop")  # Calculates the false negatives

    # ---- Step 6: Merge and compute accuracy ----
    final_eval <- hg19_chr_sizes %>%
        left_join(tp_df, by = "Chromosome") %>%
        left_join(fp_df, by = "Chromosome") %>%
        left_join(fn_df, by = "Chromosome") %>%
        mutate(across(c(TP_bp, FP_bp, FN_bp), ~replace_na(.,
            0))) %>%
        mutate(CNV_bp = TP_bp + FP_bp + FN_bp, TN_bp = Genome_bp -
            CNV_bp, Accuracy = (TP_bp + TN_bp)/Genome_bp, CNV_Only_Accuracy = ifelse((TP_bp +
            FP_bp + FN_bp) == 0, NA, TP_bp/(TP_bp + FP_bp + FN_bp))) %>%
        arrange(as.numeric(Chromosome))  # Joins all the analysis together, so it can be seen at once, and then calculates the accuracy across each case

    accuracy <- sum(final_eval$Accuracy)/22

    return(list(final_eval, accuracy))
}

This takes the processed dataframes from above, and checks against all possibilities, true negatives, true positives, and their false counterparts. It has been commented appropriately for understanding, as they all interact with each other.

Gene level analysis

There are a lot of moving parts to this visualization. This is done step by step. The below function annotates the dataframe from org.Hs.eg.db (a database of Homo Sapiens genomes), using Entrez genes. This will then enable a post processing step to generate the graphs which I showed earlier.

This happens by:

  • Annotating the genes initially with the Entrez gene database

  • It then puts both of them into GRanges to intersect the two to make sure that we don’t call segments that aren’t a part of the genes we are studying

  • It then annotates the segments with their relevant genes.

  • It can happen that sometimes genes are split across two software-generated segments or SNP segments. In these cases, we take the average of the segments.

NoGraphGeneGen <- function(Gene, db = NULL, case) {
    # Updated function.

    # This section annotates the processed dataframe with
    # genes by Querying Entrez to get the genes we want to,
    # get their locations Overlap those locations onto the
    # existing dataframe, and voila We know where the genes
    # are!
    entrez_idsDB <- mapIds(org.Hs.eg.db, keys = Gene, column = "ENTREZID",
        keytype = "SYMBOL", multiVals = "first")
    chr_locations <- AnnotationDbi::select(org.Hs.eg.db, keys = entrez_idsDB,
        columns = c("CHR", "CHRLOC", "CHRLOCEND"), keytype = "ENTREZID")
    txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
    gene_ranges <- genes(txdb)
    target_genes_ranges <- gene_ranges[gene_ranges$gene_id %in%
        entrez_idsDB]
    coords_df <- as.data.frame(target_genes_ranges)
    coords_df$entrez_id <- target_genes_ranges$gene_id
    coords_final <- coords_df[, c("entrez_id", "seqnames", "start",
        "end", "strand", "width")] %>%
        dplyr::mutate(chrom = seqnames) %>%
        dplyr::mutate(chrom = as.numeric(gsub("chr", "", chrom)),
            Gene = Gene) %>%
        dplyr::select(-c(seqnames))
    rownames(coords_final) <- Gene

    if (!is.null(db)) {
        print("is here")
        dt <- db %>%
            dplyr::filter((Gene == "0")) %>%
            dplyr::mutate(Gene = NA)  # We make sure we don't hold onto anything that
        # is not associated with a gene

        gcoords <- coords_final %>%
            dplyr::mutate(loc.start = as.numeric(start), loc.end = as.numeric(end)) %>%
            dplyr::mutate(seg.mean = 0, CNVStatus = "Normal",
                type = "Gene") %>%
            dplyr::mutate(Gene = Gene) %>%
            dplyr::select(-c("strand", "width", "entrez_id",
                "start", "end"))

        grC <- makeGRangesFromDataFrame(gcoords, start.field = "loc.start",
            end.field = "loc.end", keep.extra.columns = TRUE)
        grDt <- makeGRangesFromDataFrame(dt, start.field = "loc.start",
            end.field = "loc.end", keep.extra.columns = TRUE)

        overlaps <- findOverlaps(grDt, grC)

        # Extract intersection and bind gene annotation
        # immediately before any row changes
        intersection_df <- as.data.frame(pintersect(grDt[queryHits(overlaps)],
            grC[subjectHits(overlaps)])) %>%
            dplyr::select(-c("strand", "width", "hit", "Gene")) %>%
            dplyr::rename(loc.start = start, loc.end = end) %>%
            dplyr::mutate(chrom = as.numeric(seqnames)) %>%
            dplyr::select(-c("seqnames"))

        gene_annotations <- coords_final[subjectHits(overlaps),
            "Gene", drop = FALSE]
        overlapping_regions <- cbind(intersection_df, Gene = gene_annotations$Gene)

        # Find genes with no overlap for each type
        all_types <- unique(dt$type)
        missing_rows <- list()

        for (t in all_types) {
            # Detects if the gene is split between two or
            # more segments by taking the average instead
            dt_type <- dt %>%
                dplyr::filter(type == t)
            grDt_type <- makeGRangesFromDataFrame(dt_type, start.field = "loc.start",
                end.field = "loc.end", keep.extra.columns = TRUE)
            matched_genes <- unique(overlapping_regions$Gene[overlapping_regions$type ==
                t])
            missing_genes <- setdiff(rownames(coords_final),
                matched_genes)

            for (g in missing_genes) {
                gene_row <- coords_final[g, ]
                gene_mid <- (gene_row$start + gene_row$end)/2

                # Find flanking segments on same chromosome
                dt_chr <- dt_type %>%
                  dplyr::filter(chrom == gene_row$chrom)

                if (nrow(dt_chr) == 0)
                  next

                # Left flank: segments ending before gene
                # midpoint
                left <- dt_chr %>%
                  dplyr::filter(loc.end < gene_mid) %>%
                  dplyr::slice_max(loc.end, n = 1)
                # Right flank: segments starting after gene
                # midpoint
                right <- dt_chr %>%
                  dplyr::filter(loc.start > gene_mid) %>%
                  dplyr::slice_min(loc.start, n = 1)

                if (nrow(left) == 0 || nrow(right) == 0)
                  next

                avg_seg <- mean(c(left$seg.mean, right$seg.mean))
                avg_cnv <- ifelse(left$CNVStatus == right$CNVStatus,
                  left$CNVStatus, "Normal")

                missing_rows[[length(missing_rows) + 1]] <- data.frame(chrom = gene_row$chrom,
                  loc.start = gene_row$start, loc.end = gene_row$end,
                  seg.mean = avg_seg, type = t, CNVStatus = avg_cnv,
                  Gene = g, stringsAsFactors = FALSE)
            }
        }

        if (length(missing_rows) > 0)
            {
                overlapping_regions <- rbind(overlapping_regions,
                  dplyr::bind_rows(missing_rows))
            }  # Makes sure we have gotten everything

        overlapping_regions <- unique(overlapping_regions[c(6,
            1, 2, 3, 4, 5, 7)])
        overlapping_regions$type <- ifelse(overlapping_regions$type ==
            "Conumee", "Gene_Conumee", ifelse(overlapping_regions$type ==
            "SeSAMe", "Gene_SeSAMe", ifelse(overlapping_regions$type ==
            "MethylMaster", "Gene_MMasteR", ifelse(overlapping_regions$type ==
            "SNP", "Gene_SNP", "Unknown"))))
        overlapping_regions <- overlapping_regions %>%
            dplyr::mutate(case = case)
        overlapping_regions

    } else {
        coords_final
    }
}

We then now have to deal with visualizations.

ap10000 <- NULL
ap50000 <- NULL
ap1e05 <- NULL
ap1e06 <- NULL
Gene <- c("MYC", "MYOCD", "CCNE1", "CDKN2A", "PTEN", "RB1", "TP53")

for (stt in stts) {
    ap10000 <- rbind(ap10000, NoGraphGeneGen(Gene = Gene, db = rbind(labLMSProc(stt,
        "MethylMaster", 10000), labLMSProc(stt, "Conumee", 10000),
        labLMSProc(stt, "Sesame", 10000)), case = stt))
    ap50000 <- rbind(ap50000, NoGraphGeneGen(Gene = Gene, db = rbind(labLMSProc(stt,
        "MethylMaster", 50000), labLMSProc(stt, "Conumee", 50000),
        labLMSProc(stt, "Sesame", 50000)), case = stt))
    ap1e05 <- rbind(ap1e05, NoGraphGeneGen(Gene = Gene, db = rbind(labLMSProc(stt,
        "MethylMaster", 1e+05), labLMSProc(stt, "Conumee", 1e+05),
        labLMSProc(stt, "Sesame", 1e+05)), case = stt))
    ap1e06 <- rbind(ap1e06, NoGraphGeneGen(Gene = Gene, db = rbind(labLMSProc(stt,
        "MethylMaster", 1e+06), labLMSProc(stt, "Conumee", 1e+06),
        labLMSProc(stt, "Sesame", 1e+06)), case = stt))
}
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"
## [1] "is here"

We go through all the potential cases to understand what we are dealing with and so that we can implement the visualization by processing the data appropriately.

# Saving raw data
ap10000 <- ap10000 %>%
    dplyr::mutate(bin = 10000)
ap50000 <- ap50000 %>%
    dplyr::mutate(bin = 50000)
ap1e05 <- ap1e05 %>%
    dplyr::mutate(bin = 1e+05)
ap1e06 <- ap1e06 %>%
    dplyr::mutate(bin = 1e+06)
ap <- rbind(ap10000, ap50000, ap1e05, ap1e06) %>%
    dplyr::select(-c("chrom")) %>%
    dplyr::mutate(width = loc.end - loc.start)
ap <- split(ap, ap$Gene)

for (i in seq_along(ap)) {
    file_name <- paste0(names(ap)[i], ".csv")
    write.csv(ap[[i]], file = paste0("~/Work/Analysis/Statistics/LabLMS/GeneConcordance/rawData/",
        file_name), row.names = FALSE)
}
ap[[Gene[1]]] <- split(ap[[Gene[1]]], ap[[Gene[1]]]$bin)
ap[[Gene[2]]] <- split(ap[[Gene[2]]], ap[[Gene[2]]]$bin)
ap[[Gene[3]]] <- split(ap[[Gene[3]]], ap[[Gene[3]]]$bin)
ap[[Gene[4]]] <- split(ap[[Gene[4]]], ap[[Gene[4]]]$bin)
ap[[Gene[5]]] <- split(ap[[Gene[5]]], ap[[Gene[5]]]$bin)
ap[[Gene[6]]] <- split(ap[[Gene[6]]], ap[[Gene[6]]]$bin)
ap[[Gene[7]]] <- split(ap[[Gene[7]]], ap[[Gene[7]]]$bin)

We split everything across into genes, so that we can visualize it by gene instead of by just bin or case, as those aren’t really interesting by themselves for this usecase.

# Looking for concordance
genes <- names(ap)
bins <- c("50000", "10000", "1e+05", "1e+06")
states <- c("Conumee – default bin size", "Conumee – 10kb",
    "Conumee – 100kb", "Conumee – 1Mb", "Sesame – default bin size",
    "Sesame – 10kb", "Sesame – 100kb", "Sesame – 1Mb",
    "MethylMasteR – default bin size", "MethylMasteR – 10kb",
    "MethylMasteR – 100kb", "MethylMasteR – 1Mb")


CCNE1 <- c(1:length(states))
CDKN2A <- c(1:length(states))
MYC <- c(1:length(states))
MYOCD <- c(1:length(states))
PTEN <- c(1:length(states))
RB1 <- c(1:length(states))
TP53 <- c(1:length(states))

output.df <- data.frame(states, CCNE1, CDKN2A, MYC, MYOCD, PTEN,
    RB1, TP53)
i <- 0
j <- 0
for (i in seq_along(ap)) {
    for (j in bins) {
        Methyl <- ap[[i]][[j]] %>%
            dplyr::filter(type == "Gene_MMasteR") %>%
            dplyr::mutate(seg.mean = as.numeric(seg.mean))
        Ses <- ap[[i]][[j]] %>%
            dplyr::filter(type == "Gene_SeSAMe") %>%
            dplyr::mutate(seg.mean = as.numeric(seg.mean))
        Con <- ap[[i]][[j]] %>%
            dplyr::filter(type == "Gene_Conumee") %>%
            dplyr::mutate(seg.mean = as.numeric(seg.mean))
        Snp <- ap[[i]][[j]] %>%
            dplyr::filter(type == "Gene_SNP") %>%
            dplyr::mutate(seg.mean = as.numeric(seg.mean))
        Snp <- Snp %>%
            group_by(case) %>%
            summarize(log2ratio = mean(seg.mean))

        mCorr <- cor(Methyl$seg.mean, Snp$log2ratio)
        sCorr <- cor(Ses$seg.mean, Snp$log2ratio)
        cCorr <- cor(Con$seg.mean, Snp$log2ratio)

        print(paste0(mCorr, " ", sCorr, " ", cCorr))
        tag <- 0
        if (j == "50000") {
            tag <- 1
        }
        if (j == "10000") {
            tag <- 2
        }
        if (j == "1e+05") {
            tag <- 3
        }
        if (j == "1e+06") {
            tag <- 4
        }

        output.df[tag, i + 1] <- mCorr
        output.df[tag + 4, i + 1] <- sCorr
        output.df[tag + 8, i + 1] <- cCorr
    }
}
## [1] "0.826417880352618 0.813440323796319 0.845943210618849"
## [1] "0.849134403884159 0.836896340412142 0.844368393910045"
## [1] "0.843005346823355 0.829474876393488 0.831894387147325"
## [1] "0.79489252657153 0.805152583360047 0.845781813166039"
## [1] "0.770286775383964 0.824711869003358 0.820810622368492"
## [1] "0.784476652907735 0.842870595760608 0.837815008814301"
## [1] "0.828431908549295 0.863729216325694 0.814386084893461"
## [1] "0.776951840796653 0.809258743289404 0.843185857302898"
## [1] "0.550119920847339 0.533111942514943 0.623517986495779"
## [1] "0.594882099031743 0.513851869692022 0.379050348014905"
## [1] "0.728429963922226 0.590602707782826 0.616991728990406"
## [1] "0.599560636492384 0.493157855491004 0.613060168297233"
## [1] "0.703082777869045 0.737155429945174 0.757266803619211"
## [1] "0.759241487110125 0.721856082001065 0.743062822010953"
## [1] "0.788779978335249 0.738024751153176 0.744233670582984"
## [1] "0.737604178197128 0.736457605970674 0.755436379247107"
## [1] "0.173994453322823 0.201614441620541 0.158087271330171"
## [1] "0.183646163979431 0.212871187889706 0.0466493488085179"
## [1] "0.156183661438954 0.212959236115107 0.174572305471204"
## [1] "-0.00562029336073261 0.0525883803472474 0.00346858286312494"
## [1] "0.284964544161419 -0.103117646873573 0.55669826414135"
## [1] "0.273210786726921 0.0727401864100489 0.409547861912897"
## [1] "0.444760905459316 -0.022745446473997 0.34792966700185"
## [1] "0.395649026750018 0.328853019174688 0.689928235069948"
## [1] "0.92032642794316 0.895923294419126 0.889208352500564"
## [1] "0.91015423233901 0.887451563223858 0.831874713823817"
## [1] "0.925389940484122 0.898103823567314 0.894178403267808"
## [1] "0.838169101292533 0.911586067526427 0.898609062298142"
# Melt to long format
df_long <- melt(output.df, id.vars = "states", variable.name = "gene",
    value.name = "correlation")

# Keep row order
df_long$states <- factor(df_long$states, levels = rev(output.df$states))

# Plot
p <- ggplot(df_long, aes(x = gene, y = states, fill = correlation)) +
    geom_tile(color = "black", linewidth = 0.5) + geom_text(aes(label = sprintf("%.2f",
    correlation)), size = 3, color = "black") + scale_fill_gradient2(low = "#2166ac",
    mid = "#f7f7f7", high = "#50C878", midpoint = 0.5, limits = c(min(df_long$correlation),
        1), name = "Correlation") + labs(title = "CNV Method Comparison by Gene",
    x = "Gene", y = "Method & Bin Size") + theme_minimal(base_size = 12) +
    theme(plot.title = element_text(hjust = 0.5, face = "bold",
        size = 14), axis.text.x = element_text(angle = 30, hjust = 1,
        face = "bold"), axis.text.y = element_text(size = 9),
        panel.grid = element_blank(), legend.position = "right")

This code develops the correlation by using the “cor” function.

This correlation is taking the correlation of the log2 ratios of the genes we are studying across the cases.

What this means is that each case being studied has a log2 ratio value associated to a gene. The PCC is taken across those values for each genes.

It is pretty simplistic, it places the correlation value from Pearson’s Correlation Coefficient into an output dataframe. It then melts the gene into the appropriate matrix, and then makes it into a plot.

Visualizations

The visualization suite is pretty simple.

plot_cnv_segments <- function(df, anno = NULL) {
  
  df <- df %>%
    mutate(
      type_group = ifelse(type == "SNP", "SNP", "non-SNP")
    ) %>%
    arrange(chrom, loc.start)
  
  df$seg.mean <- as.numeric(df$seg.mean)
  
  # Calculate chromosome cumulative positions
  chr_lengths <- df %>%
    dplyr::group_by(chrom) %>%
    dplyr::summarize(chr_len = max(loc.end), .groups = "drop") %>%
    arrange(chrom) %>%
    mutate(chr_start = lag(cumsum(chr_len), default = 0)) %>%
    mutate(chr_mid = chr_start + chr_len / 2)
  print(chr_lengths)
  df <- df %>%
    left_join(chr_lengths, by = "chrom") %>%
    mutate(
      start_cum = loc.start + chr_start,
      end_cum = loc.end + chr_start
    ) %>%mutate(type = ifelse(type == "SNP", "SNP", type)) %>% 
    mutate(type = as.factor(type))
  
  # Vertical chromosome boundaries
  chr_boundaries <- chr_lengths %>%
    mutate(x = chr_start) %>%
    dplyr::select(chrom, x)
  
  x_breaks <- chr_lengths$chr_mid
  x_labels <- paste0("chr", chr_lengths$chrom)
  x_labels <- c(x_labels)
  print(x_labels)
  print(df)
  df$Gene[df$Gene == "0"] <- NA
  
  # Plot
  p <- ggplot(df, aes(x = start_cum, xend = end_cum, y = seg.mean, yend = seg.mean, label = Gene)) +
    geom_segment(aes(color = type), size = 0.7, alpha = 0.8) +
    geom_point(data = subset(df, type == "Gene_Conumee"), aes(x = start_cum, y = seg.mean, label = Gene), color = "green", size = 3) + 
    geom_point(data = subset(df, type == "Gene_SNP"), aes(x = start_cum, y = seg.mean, label = Gene), color = "gray40", size = 3) + 
    geom_point(data = subset(df, type == "Gene_SeSAMe"), aes(x = start_cum, y = seg.mean, label = Gene), color = "red", size = 3) + 
    geom_point(data = subset(df, type == "Gene_MMasteR"), aes(x = start_cum, y = seg.mean, label = Gene), color = "blue", size = 3) + 
    geom_text_repel(
      box.padding = unit(0.35, "lines"), # Adjust padding around the label
      point.padding = unit(0.3, "lines"), # Adjust padding around the point
      segment.color = 'grey' # Color of the connecting lines
    ) +
    geom_vline(data = chr_boundaries, aes(xintercept = x), color = "grey70", linetype = "dashed") +
    # scale_color_manual(values = c("Amplification" = "red", "Deletion" = "blue", "Normal" = "black")) +
    scale_x_continuous(breaks = x_breaks, labels = x_labels) +
    scale_color_manual(values = c("SeSAMe" = "red", "MethylMaster" = "blue", 
                                  "Conumee" = "green", "SNP" = "black", "Gene" = "orange")) +
    labs(
      x = "Genomic Position (across chromosomes)",
      y = "Segment Mean (log2 ratio)",
      title = "CNV Segments Across Genome"
    ) + geom_hline(yintercept = -0.2, linetype = "dotted", color = "black") + 
    geom_hline(yintercept = 0.2, linetype = "dotted", color = "black") + 
    scale_y_continuous(breaks = c(-0.75, -0.5, -0.25, 0, 0.25,0.5,0.75)) +
    theme_minimal() +
    theme(
      panel.grid.major.y = element_line(color = "grey90"),
      panel.grid.major.x = element_blank(),
      legend.position = "bottom"
    )
  
  return(p)
}

The above code plots the Manhattan plots I have been showing off. It takes a dataframe preprocessed by the above functions, and then it sorts it , calculates the median positions to place every chromosome upon, finds the upper and lower bounds, and then plots everything on the plot I have shown before.

geneGen <- function(Gene, db = NULL){
  entrez_idsDB <- mapIds(org.Hs.eg.db, 
                         keys=Gene, 
                         column="ENTREZID", 
                         keytype="SYMBOL",
                         multiVals="first")
  chr_locations <- AnnotationDbi::select(org.Hs.eg.db,
                                         keys = entrez_idsDB,
                                         columns = c("CHR", "CHRLOC", "CHRLOCEND"),
                                         keytype = "ENTREZID")
  txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
  gene_ranges <- genes(txdb)
  target_genes_ranges <- gene_ranges[gene_ranges$gene_id %in% entrez_idsDB]
  coords_df <- as.data.frame(target_genes_ranges)
  coords_df$entrez_id <- target_genes_ranges$gene_id
  coords_final <- coords_df[, c("entrez_id", "seqnames", "start", "end", 
                                "strand", "width")] %>% 
    dplyr::mutate(chrom=seqnames) %>% 
    dplyr::mutate(chrom = as.numeric(gsub("chr","",chrom)), 
                  Gene = rownames(.)) %>% 
    dplyr::select(-c(seqnames))
  rownames(coords_final) <- Gene
  if(!is.null(db)){
    print("is here")
    dt <- db %>% dplyr::filter((Gene == "0")) %>% 
      dplyr::mutate(Gene = NA)
    gcoords <- coords_final %>% 
      dplyr::mutate(loc.start = as.numeric(start), loc.end = as.numeric(end)) %>% 
      dplyr::mutate(seg.mean = 0, CNVStatus = "Normal", type = "Gene") %>%
      dplyr::mutate(Gene = Gene) %>% 
      dplyr::select(-c("strand", "width", "entrez_id", "start", "end"))
    grC <- makeGRangesFromDataFrame(gcoords, 
                                    start.field = "loc.start",
                                    end.field = "loc.end",
                                    keep.extra.columns = TRUE)
    grDt <- makeGRangesFromDataFrame(dt,
                                     start.field = "loc.start",
                                     end.field = "loc.end",
                                     keep.extra.columns = TRUE)
    overlaps <- findOverlaps(grDt, grC)
    overlapping_regions <- pintersect(grDt[queryHits(overlaps)], grC[subjectHits(overlaps)])
    overlapping_regions <- as.data.frame(overlapping_regions) %>% 
      dplyr::select(-c("strand", "width", "hit", "Gene")) %>%
      dplyr::rename(loc.start = start, loc.end = end) %>%
      dplyr::mutate(chrom = as.numeric(seqnames)) %>%
      dplyr::select(-c("seqnames"))
    overlapping_regions <- dplyr::left_join(overlapping_regions, coords_final, 
                                            by=c("chrom"="chrom",
                                                 "loc.start" = "start", 
                                                 "loc.end" = "end")) %>%
      dplyr::select(-c("entrez_id", "strand", "width")) 
    overlapping_regions <- unique(overlapping_regions[c(6, 1, 2, 3, 4, 5, 7)])
    overlapping_regions$type <- ifelse(
      overlapping_regions$type == "Conumee", "Gene_Conumee",
      ifelse(overlapping_regions$type == "SeSAMe", "Gene_SeSAMe", 
             ifelse(overlapping_regions$type == "MethylMaster", "Gene_MMasteR",
                    ifelse(overlapping_regions$type == "SNP", "Gene_SNP", "Unknown")))
    )
    overlapping_regions <- overlapping_regions %>% drop_na()
    print(overlapping_regions)
    # Developing visualization
    mat <- matrix(NA, nrow = 4, ncol = length(unique(overlapping_regions$Gene)))
    overlapping_regions <- overlapping_regions %>% drop_na()
    print(unique(overlapping_regions$type))
    colnames(mat) <- unique(overlapping_regions$Gene)
    rownames(mat) <- unique(overlapping_regions$type)
    for (i in 1:nrow(overlapping_regions)) {
      row_index <- match(overlapping_regions$type[i], rownames(mat))
      col_index <- match(overlapping_regions$Gene[i], colnames(mat))
      mat[row_index, col_index] <- as.numeric(overlapping_regions$seg.mean[i])
    }
    mat[is.na(mat)] <- 0
    print(mat)
    colors <- rev(brewer.pal(n = 7, name = "RdBu"))
    labels_matrix <- matrix(sprintf("%.3f", mat), 
                            nrow = nrow(mat), 
                            ncol = ncol(mat))
    ph <- pheatmap(
      mat,
      color = colors,
      scale = "row", # Scales the values in each row/column/none to a z-score
      cluster_rows = FALSE,
      cluster_cols = FALSE,
      show_rownames = TRUE, # Set to TRUE if you have few genes
      display_numbers = labels_matrix,
      main = "Gene Expression Heatmap (Log2 Ratio / Z-score)"
    )
    list(ph, overlapping_regions)
    
  } else {
    coords_final
  }
}

This above code is basically identical to the preprocessor in the gene-level analysis. It is merely that this includes some post-processing into a matrix to make a heatmap, and create the heatmap itself using a pheatmap.

geneAnno <- function(Gene, db = NULL) {
    reference <- geneGen(Gene = Gene, db = db)
    print(reference[[1]])
    pheatmap_ggplot <- as.ggplot(reference[[1]]$gtable)
    reference2 <- reference[[2]]
    db <- unique(rbind(db, reference2))
    img2 <- plot_cnv_segments(db)
    return(list((img2 + pheatmap_ggplot + plot_layout(widths = unit(c(20,
        8), c("null", "null")))), db))
}

This combines the two, the gene heatmap and the Manhattan plot, into one singular plot.

A Run-through

Talking about code feels very abstract, so below is a little runthrough of ALL the code, taking through how a typical set of samples would be analyzed. Some of the driver code is dropped because it muddles understanding, but can be explained if needed.

Let’s take the code to be analysing case STT 9202, an LMS case, at 10000 basepair bins.

df <- rbind(labLMSProc(9202, "MethylMaster", 10000), labLMSProc(9202,
    "Sesame", 10000), labLMSProc(9202, "Conumee", 10000))  # This creates the full database of data for that case at that basepair bin.
print(df)
##          seg.mean loc.start   loc.end chrom         type     CNVStatus Gene
## 1   -0.3777818159    747994  28115000     1 MethylMaster      Deletion    0
## 2   -0.7534818159  28185000  28505000     1 MethylMaster      Deletion    0
## 3   -0.4224818159  28530000  38525000     1 MethylMaster      Deletion    0
## 4    0.1562181841  38690000 186405000     1 MethylMaster        Normal    0
## 5    0.3858181841 186560000 199570000     1 MethylMaster Amplification    0
## 6    0.1513181841 199885000 208295000     1 MethylMaster        Normal    0
## 7   -0.3127818159 208480000 248923211     1 MethylMaster      Deletion    0
## 8   -0.5230000000    754192  39046130     1          SNP      Deletion    0
## 9    0.3290000000  39053684  71837405     1          SNP Amplification    0
## 10   0.5860000000  71858457  72654730     1          SNP Amplification    0
## 11   0.3720000000  72662685  76640953     1          SNP Amplification    0
## 12  -0.0230000000  76658494  77726109     1          SNP        Normal    0
## 13   0.3400000000  77737217  93047956     1          SNP Amplification    0
## 14   0.0030000000  93073228  98750052     1          SNP        Normal    0
## 15   0.3250000000  98766448 100543962     1          SNP Amplification    0
## 16  -0.0280000000 100549400 110221639     1          SNP        Normal    0
## 17   0.2600000000 110222219 111181086     1          SNP Amplification    0
## 18  -0.0210000000 111193595 152411090     1          SNP        Normal    0
## 19   0.3470000000 152411813 208551533     1          SNP Amplification    0
## 20  -0.5640000000 208569475 249212878     1          SNP      Deletion    0
## 21  -0.3056818159    110000  46830000     2 MethylMaster      Deletion    0
## 22  -1.3103818159  46880000  49160000     2 MethylMaster      Deletion    0
## 23  -0.3053818159  49835000 200815000     2 MethylMaster      Deletion    0
## 24  -0.5376818159 200840000 201305000     2 MethylMaster      Deletion    0
## 25  -0.3142818159 201405000 242111765     2 MethylMaster      Deletion    0
## 26  -0.5260000000     21494  47051551     2          SNP      Deletion    0
## 27  -1.6880000000  47067057  49997218     2          SNP      Deletion    0
## 28  -0.5610000000  50007748 243052331     2          SNP      Deletion    0
## 29   0.0185181841    115000 198097780     3 MethylMaster        Normal    0
## 30  -0.0690000000     63411 197852564     3          SNP        Normal    0
## 31   0.0581181841    110000 190066561     4 MethylMaster        Normal    0
## 32  -0.5940000000     69404    334213     4          SNP      Deletion    0
## 33  -0.0470000000    360026 180023290     4          SNP        Normal    0
## 34  -0.4110000000 180040368 180365623     4          SNP      Deletion    0
## 35  -0.0540000000 180392930 190915650     4          SNP        Normal    0
## 36   0.0446181841     50000 181369130     5 MethylMaster        Normal    0
## 37  -0.0080000000     38139    392863     5          SNP        Normal    0
## 38   0.2300000000    412226    788914     5          SNP Amplification    0
## 39  -0.0070000000    804103 180698312     5          SNP        Normal    0
## 40  -0.0131818159    140000 170662990     6 MethylMaster        Normal    0
## 41  -0.0320000000    204909 170913051     6          SNP        Normal    0
## 42  -0.3608818159     50000 159247987     7 MethylMaster      Deletion    0
## 43  -0.5470000000     41421 159118443     7          SNP      Deletion    0
## 44   0.0127181841    195000 145039318     8 MethylMaster        Normal    0
## 45  -0.0200000000    172417  39194984     8          SNP        Normal    0
## 46  -1.6230000000  39217074  39460780     8          SNP      Deletion    0
## 47  -0.0250000000  39480366 146292734     8          SNP        Normal    0
## 48  -0.0264818159    215000 138187359     9 MethylMaster        Normal    0
## 49  -0.0240000000    204738   5021738     9          SNP        Normal    0
## 50  -0.2510000000   5023689   5069837     9          SNP      Deletion    0
## 51  -0.0480000000   5071049 129580187     9          SNP        Normal    0
## 52  -0.2400000000 129582563 129844541     9          SNP      Deletion    0
## 53   0.0000000000 129854773 141054761     9          SNP        Normal    0
## 54   0.0141181841    125000  74415000    10 MethylMaster        Normal    0
## 55  -0.3479818159  74595000 133625233    10 MethylMaster      Deletion    0
## 56  -0.0340000000    126070  76263261    10          SNP        Normal    0
## 57  -0.5810000000  76287336 135434303    10          SNP      Deletion    0
## 58  -0.0006818159    145000  62735000    11 MethylMaster        Normal    0
## 59  -0.3424818159  62760000  62840000    11 MethylMaster      Deletion    0
## 60  -0.0074818159  62865000 134993311    11 MethylMaster        Normal    0
## 61  -0.0150000000    192764 134938847    11          SNP        Normal    0
## 62   0.0027181841     70000 133222655    12 MethylMaster        Normal    0
## 63  -0.0310000000    189400 133818115    12          SNP        Normal    0
## 64   0.0403181841  18679053  47270000    13 MethylMaster        Normal    0
## 65  -0.3266818159  47630000  61950000    13 MethylMaster      Deletion    0
## 66   0.0940181841  63095000 114332164    13 MethylMaster        Normal    0
## 67  -0.0190000000  19084823  48054661    13          SNP        Normal    0
## 68  -0.5470000000  48058244  63661960    13          SNP      Deletion    0
## 69   0.0190000000  63685149 115103150    13          SNP        Normal    0
## 70   0.0220181841  19770857  71035000    14 MethylMaster        Normal    0
## 71  -0.3619818159  71155000  90290000    14 MethylMaster      Deletion    0
## 72  -0.0233818159  90360000 106751859    14 MethylMaster        Normal    0
## 73  -0.0220000000  20219083  71568215    14          SNP        Normal    0
## 74  -0.6010000000  71580778  90801109    14          SNP      Deletion    0
## 75   0.0170000000  90815342 106836445    14          SNP        Normal    0
## 76  -0.2410000000 106839840 106931347    14          SNP      Deletion    0
## 77  -0.0370000000 106931821 107282024    14          SNP        Normal    0
## 78  -0.0141818159  20232279 101850595    15 MethylMaster        Normal    0
## 79  -0.0180000000  20161372  44502266    15          SNP        Normal    0
## 80   0.2050000000  44514571  44777942    15          SNP Amplification    0
## 81  -0.0040000000  44788617 102397317    15          SNP        Normal    0
## 82  -0.0895818159     40000  48010000    16 MethylMaster        Normal    0
## 83  -0.3532818159  48160000  54995000    16 MethylMaster      Deletion    0
## 84  -0.0350818159  55185000  55785000    16 MethylMaster        Normal    0
## 85  -0.3510818159  55925000  56730000    16 MethylMaster      Deletion    0
## 86  -0.0746818159  56820000  57925000    16 MethylMaster        Normal    0
## 87  -0.3635818159  57995000  90149173    16 MethylMaster      Deletion    0
## 88   0.0300000000     83887  48175235    16          SNP        Normal    0
## 89  -0.5670000000  48185960  55137655    16          SNP      Deletion    0
## 90   0.0520000000  55156505  55879117    16          SNP        Normal    0
## 91  -0.5860000000  55889730  56698268    16          SNP      Deletion    0
## 92   0.0290000000  56724810  57983711    16          SNP        Normal    0
## 93  -0.5640000000  58011450  90158005    16          SNP      Deletion    0
## 94  -0.0707818159    130000  68480000    17 MethylMaster        Normal    0
## 95   0.1569181841  68530000  72070000    17 MethylMaster        Normal    0
## 96  -0.0682818159  72115000  83168721    17 MethylMaster        Normal    0
## 97   0.0000000000    400959  80263427    17          SNP        Normal    0
## 98   0.0574181841    135000  80206643    18 MethylMaster        Normal    0
## 99   0.0010000000     12842  78007784    18          SNP        Normal    0
## 100 -0.1467818159    175000  29890000    19 MethylMaster        Normal    0
## 101  0.0527181841  29975000  32370000    19 MethylMaster        Normal    0
## 102 -0.1348818159  32490000  34390000    19 MethylMaster        Normal    0
## 103 -0.4709818159  34455000  58588808    19 MethylMaster      Deletion    0
## 104  0.0100000000    247232  20170214    19          SNP        Normal    0
## 105 -0.3030000000  20179614  20462595    19          SNP      Deletion    0
## 106 -0.0540000000  20473553  34916011    19          SNP        Normal    0
## 107 -0.5750000000  34931904  59093239    19          SNP      Deletion    0
## 108 -0.0246818159    178168  64292084    20 MethylMaster        Normal    0
## 109 -0.0130000000     69094  62912463    20          SNP        Normal    0
## 110  0.0343181841  10569444  46679992    21 MethylMaster        Normal    0
## 111  0.0440000000   9648315  48097610    21          SNP        Normal    0
## 112 -0.0662818159  16567005  50769234    22 MethylMaster        Normal    0
## 113  0.0300000000  16054713  24341388    22          SNP        Normal    0
## 114  0.6420000000  24346428  24390318    22          SNP Amplification    0
## 115  0.0210000000  24394088  51213826    22          SNP        Normal    0
## 116 -0.3008000000    677994  16510000     1       SeSAMe      Deletion    0
## 117  0.0215000000  16570000  16779582     1       SeSAMe        Normal    0
## 118 -0.3448000000  16869582  28185000     1       SeSAMe      Deletion    0
## 119 -0.6069000000  28275000  28695000     1       SeSAMe      Deletion    0
## 120 -0.3593000000  28795000  38525000     1       SeSAMe      Deletion    0
## 121  0.2126000000  38690000 186405000     1       SeSAMe        Normal    0
## 122  0.4444000000 186560000 199570000     1       SeSAMe Amplification    0
## 123  0.2130000000 199885000 208295000     1       SeSAMe        Normal    0
## 124 -0.2521000000 208480000 248923211     1       SeSAMe        Normal    0
## 125 -0.5230000000    754192  39046130     1          SNP      Deletion    0
## 126  0.3290000000  39053684  71837405     1          SNP Amplification    0
## 127  0.5860000000  71858457  72654730     1          SNP Amplification    0
## 128  0.3720000000  72662685  76640953     1          SNP Amplification    0
## 129 -0.0230000000  76658494  77726109     1          SNP        Normal    0
## 130  0.3400000000  77737217  93047956     1          SNP Amplification    0
## 131  0.0030000000  93073228  98750052     1          SNP        Normal    0
## 132  0.3250000000  98766448 100543962     1          SNP Amplification    0
## 133 -0.0280000000 100549400 110221639     1          SNP        Normal    0
## 134  0.2600000000 110222219 111181086     1          SNP Amplification    0
## 135 -0.0210000000 111193595 152411090     1          SNP        Normal    0
## 136  0.3470000000 152411813 208551533     1          SNP Amplification    0
## 137 -0.5640000000 208569475 249212878     1          SNP      Deletion    0
## 138 -0.2467000000    110000  46830000     2       SeSAMe        Normal    0
## 139 -1.2535000000  46880000  49160000     2       SeSAMe      Deletion    0
## 140 -0.2428000000  49835000 200815000     2       SeSAMe        Normal    0
## 141 -0.4734000000 200840000 201305000     2       SeSAMe      Deletion    0
## 142 -0.2557000000 201405000 242111765     2       SeSAMe        Normal    0
## 143 -0.5260000000     21494  47051551     2          SNP      Deletion    0
## 144 -1.6880000000  47067057  49997218     2          SNP      Deletion    0
## 145 -0.5610000000  50007748 243052331     2          SNP      Deletion    0
## 146  0.0762000000    115000 198172780     3       SeSAMe        Normal    0
## 147 -0.0690000000     63411 197852564     3          SNP        Normal    0
## 148  0.1150000000     65000 190066561     4       SeSAMe        Normal    0
## 149 -0.5940000000     69404    334213     4          SNP      Deletion    0
## 150 -0.0470000000    360026 180023290     4          SNP        Normal    0
## 151 -0.4110000000 180040368 180365623     4          SNP      Deletion    0
## 152 -0.0540000000 180392930 190915650     4          SNP        Normal    0
## 153  0.1023000000     50000 181369130     5       SeSAMe        Normal    0
## 154 -0.0080000000     38139    392863     5          SNP        Normal    0
## 155  0.2300000000    412226    788914     5          SNP Amplification    0
## 156 -0.0070000000    804103 180698312     5          SNP        Normal    0
## 157  0.0438000000    140000 170662990     6       SeSAMe        Normal    0
## 158 -0.0320000000    204909 170913051     6          SNP        Normal    0
## 159 -0.3015000000     50000 159247987     7       SeSAMe      Deletion    0
## 160 -0.5470000000     41421 159118443     7          SNP      Deletion    0
## 161  0.0701000000    160000 145039318     8       SeSAMe        Normal    0
## 162 -0.0200000000    172417  39194984     8          SNP        Normal    0
## 163 -1.6230000000  39217074  39460780     8          SNP      Deletion    0
## 164 -0.0250000000  39480366 146292734     8          SNP        Normal    0
## 165  0.0336000000    110000 138227359     9       SeSAMe        Normal    0
## 166 -0.0240000000    204738   5021738     9          SNP        Normal    0
## 167 -0.2510000000   5023689   5069837     9          SNP      Deletion    0
## 168 -0.0480000000   5071049 129580187     9          SNP        Normal    0
## 169 -0.2400000000 129582563 129844541     9          SNP      Deletion    0
## 170  0.0000000000 129854773 141054761     9          SNP        Normal    0
## 171  0.0729000000     70000  74415000    10       SeSAMe        Normal    0
## 172 -0.2900000000  74595000 133625233    10       SeSAMe        Normal    0
## 173 -0.0340000000    126070  76263261    10          SNP        Normal    0
## 174 -0.5810000000  76287336 135434303    10          SNP      Deletion    0
## 175  0.0508000000    130000 135013311    11       SeSAMe        Normal    0
## 176 -0.0150000000    192764 134938847    11          SNP        Normal    0
## 177  0.0600000000     55000 133222655    12       SeSAMe        Normal    0
## 178 -0.0310000000    189400 133818115    12          SNP        Normal    0
## 179  0.1000000000  18639053  47270000    13       SeSAMe        Normal    0
## 180 -0.2705000000  47630000  62140000    13       SeSAMe        Normal    0
## 181  0.1508000000  63120000 114332164    13       SeSAMe        Normal    0
## 182 -0.0190000000  19084823  48054661    13          SNP        Normal    0
## 183 -0.5470000000  48058244  63661960    13          SNP      Deletion    0
## 184  0.0190000000  63685149 115103150    13          SNP        Normal    0
## 185  0.0794000000  19187179  71035000    14       SeSAMe        Normal    0
## 186 -0.3041000000  71155000  90290000    14       SeSAMe      Deletion    0
## 187  0.0322000000  90360000 106796859    14       SeSAMe        Normal    0
## 188 -0.0220000000  20219083  71568215    14          SNP        Normal    0
## 189 -0.6010000000  71580778  90801109    14          SNP      Deletion    0
## 190  0.0170000000  90815342 106836445    14          SNP        Normal    0
## 191 -0.2410000000 106839840 106931347    14          SNP      Deletion    0
## 192 -0.0370000000 106931821 107282024    14          SNP        Normal    0
## 193 -0.3009000000  20062627  22068372    15       SeSAMe      Deletion    0
## 194  0.0452000000  22569121 101875595    15       SeSAMe        Normal    0
## 195 -0.0180000000  20161372  44502266    15          SNP        Normal    0
## 196  0.2050000000  44514571  44777942    15          SNP Amplification    0
## 197 -0.0040000000  44788617 102397317    15          SNP        Normal    0
## 198 -0.0305000000     40000  48010000    16       SeSAMe        Normal    0
## 199 -0.2948000000  48160000  54995000    16       SeSAMe        Normal    0
## 200  0.0270000000  55185000  55785000    16       SeSAMe        Normal    0
## 201 -0.2897000000  55925000  56730000    16       SeSAMe        Normal    0
## 202 -0.0154000000  56820000  57925000    16       SeSAMe        Normal    0
## 203 -0.2987000000  57995000  90159173    16       SeSAMe        Normal    0
## 204  0.0300000000     83887  48175235    16          SNP        Normal    0
## 205 -0.5670000000  48185960  55137655    16          SNP      Deletion    0
## 206  0.0520000000  55156505  55879117    16          SNP        Normal    0
## 207 -0.5860000000  55889730  56698268    16          SNP      Deletion    0
## 208  0.0290000000  56724810  57983711    16          SNP        Normal    0
## 209 -0.5640000000  58011450  90158005    16          SNP      Deletion    0
## 210 -0.0107000000    120000  68480000    17       SeSAMe        Normal    0
## 211  0.2163000000  68530000  72070000    17       SeSAMe        Normal    0
## 212 -0.0098000000  72115000  83168721    17       SeSAMe        Normal    0
## 213  0.0000000000    400959  80263427    17          SNP        Normal    0
## 214  0.1163000000     80000  80206643    18       SeSAMe        Normal    0
## 215  0.0010000000     12842  78007784    18          SNP        Normal    0
## 216 -0.0894000000    175000  29890000    19       SeSAMe        Normal    0
## 217  0.1090000000  29975000  32370000    19       SeSAMe        Normal    0
## 218 -0.0719000000  32490000  34390000    19       SeSAMe        Normal    0
## 219 -0.4152000000  34455000  53560000    19       SeSAMe      Deletion    0
## 220 -0.7416000000  53605000  53765000    19       SeSAMe      Deletion    0
## 221 -0.3768000000  53820000  58588808    19       SeSAMe      Deletion    0
## 222  0.0100000000    247232  20170214    19          SNP        Normal    0
## 223 -0.3030000000  20179614  20462595    19          SNP      Deletion    0
## 224 -0.0540000000  20473553  34916011    19          SNP        Normal    0
## 225 -0.5750000000  34931904  59093239    19          SNP      Deletion    0
## 226  0.0340000000    178168  64292084    20       SeSAMe        Normal    0
## 227 -0.0130000000     69094  62912463    20          SNP        Normal    0
## 228  0.0914000000   5055000  46679992    21       SeSAMe        Normal    0
## 229  0.0440000000   9648315  48097610    21          SNP        Normal    0
## 230 -0.0092000000  15422159  50769234    22       SeSAMe        Normal    0
## 231  0.0300000000  16054713  24341388    22          SNP        Normal    0
## 232  0.6420000000  24346428  24390318    22          SNP Amplification    0
## 233  0.0210000000  24394088  51213826    22          SNP        Normal    0
## 234 -0.3180000000     93709  39040000     1      Conumee      Deletion    0
## 235  0.1910000000  39115000  93105000     1      Conumee        Normal    0
## 236  0.0430000000  93270000  98515000     1      Conumee        Normal    0
## 237  0.2900000000  98685000 100545000     1      Conumee Amplification    0
## 238  0.0330000000 100595000 110285000     1      Conumee        Normal    0
## 239  0.1820000000 110300000 111505000     1      Conumee        Normal    0
## 240  0.0110000000 111595000 152240000     1      Conumee        Normal    0
## 241  0.1900000000 152315000 185705000     1      Conumee        Normal    0
## 242  0.3630000000 185820000 199735000     1      Conumee Amplification    0
## 243  0.1580000000 199910000 208510000     1      Conumee        Normal    0
## 244 -0.2790000000 208690000 249220311     1      Conumee      Deletion    0
## 245 -0.5230000000    754192  39046130     1          SNP      Deletion    0
## 246  0.3290000000  39053684  71837405     1          SNP Amplification    0
## 247  0.5860000000  71858457  72654730     1          SNP Amplification    0
## 248  0.3720000000  72662685  76640953     1          SNP Amplification    0
## 249 -0.0230000000  76658494  77726109     1          SNP        Normal    0
## 250  0.3400000000  77737217  93047956     1          SNP Amplification    0
## 251  0.0030000000  93073228  98750052     1          SNP        Normal    0
## 252  0.3250000000  98766448 100543962     1          SNP Amplification    0
## 253 -0.0280000000 100549400 110221639     1          SNP        Normal    0
## 254  0.2600000000 110222219 111181086     1          SNP Amplification    0
## 255 -0.0210000000 111193595 152411090     1          SNP        Normal    0
## 256  0.3470000000 152411813 208551533     1          SNP Amplification    0
## 257 -0.5640000000 208569475 249212878     1          SNP      Deletion    0
## 258 -0.2890000000     30000  47050000     2      Conumee      Deletion    0
## 259 -1.2360000000  47095000  49795000     2      Conumee      Deletion    0
## 260 -0.2900000000  50395000 243046238     2      Conumee      Deletion    0
## 261 -0.5260000000     21494  47051551     2          SNP      Deletion    0
## 262 -1.6880000000  47067057  49997218     2          SNP      Deletion    0
## 263 -0.5610000000  50007748 243052331     2          SNP      Deletion    0
## 264  0.0200000000    150000 197881215     3      Conumee        Normal    0
## 265 -0.0690000000     63411 197852564     3          SNP        Normal    0
## 266  0.0500000000     35000 190992138     4      Conumee        Normal    0
## 267 -0.5940000000     69404    334213     4          SNP      Deletion    0
## 268 -0.0470000000    360026 180023290     4          SNP        Normal    0
## 269 -0.4110000000 180040368 180365623     4          SNP      Deletion    0
## 270 -0.0540000000 180392930 190915650     4          SNP        Normal    0
## 271  0.0460000000     35000 180797630     5      Conumee        Normal    0
## 272 -0.0080000000     38139    392863     5          SNP        Normal    0
## 273  0.2300000000    412226    788914     5          SNP Amplification    0
## 274 -0.0070000000    804103 180698312     5          SNP        Normal    0
## 275  0.0250000000    130000 170977534     6      Conumee        Normal    0
## 276 -0.0320000000    204909 170913051     6          SNP        Normal    0
## 277 -0.3160000000     40000 159044332     7      Conumee      Deletion    0
## 278 -0.5470000000     41421 159118443     7          SNP      Deletion    0
## 279  0.0260000000     95000 146267011     8      Conumee        Normal    0
## 280 -0.0200000000    172417  39194984     8          SNP        Normal    0
## 281 -1.6230000000  39217074  39460780     8          SNP      Deletion    0
## 282 -0.0250000000  39480366 146292734     8          SNP        Normal    0
## 283 -0.0160000000    110000 141081716     9      Conumee        Normal    0
## 284 -0.0240000000    204738   5021738     9          SNP        Normal    0
## 285 -0.2510000000   5023689   5069837     9          SNP      Deletion    0
## 286 -0.0480000000   5071049 129580187     9          SNP        Normal    0
## 287 -0.2400000000 129582563 129844541     9          SNP      Deletion    0
## 288  0.0000000000 129854773 141054761     9          SNP        Normal    0
## 289  0.0060000000     80000  76205000    10      Conumee        Normal    0
## 290 -0.3020000000  76310000 135482374    10      Conumee      Deletion    0
## 291 -0.0340000000    126070  76263261    10          SNP        Normal    0
## 292 -0.5810000000  76287336 135434303    10          SNP      Deletion    0
## 293  0.0090000000    130000 134893258    11      Conumee        Normal    0
## 294 -0.0150000000    192764 134938847    11          SNP        Normal    0
## 295  0.0020000000    182870 133795948    12      Conumee        Normal    0
## 296 -0.0310000000    189400 133818115    12          SNP        Normal    0
## 297  0.0290000000  19100000  47985000    13      Conumee        Normal    0
## 298 -0.2610000000  48350000  63100000    13      Conumee      Deletion    0
## 299  0.0660000000  63860000 115094939    13      Conumee        Normal    0
## 300 -0.0190000000  19084823  48054661    13          SNP        Normal    0
## 301 -0.5470000000  48058244  63661960    13          SNP      Deletion    0
## 302  0.0190000000  63685149 115103150    13          SNP        Normal    0
## 303  0.0330000000  19210000  71515000    14      Conumee        Normal    0
## 304 -0.3240000000  71610000  73705000    14      Conumee      Deletion    0
## 305 -0.5770000000  73715000  74150000    14      Conumee      Deletion    0
## 306 -0.3150000000  74185000  90760000    14      Conumee      Deletion    0
## 307 -0.0080000000  90795000 107254770    14      Conumee        Normal    0
## 308 -0.0220000000  20219083  71568215    14          SNP        Normal    0
## 309 -0.6010000000  71580778  90801109    14          SNP      Deletion    0
## 310  0.0170000000  90815342 106836445    14          SNP        Normal    0
## 311 -0.2410000000 106839840 106931347    14          SNP      Deletion    0
## 312 -0.0370000000 106931821 107282024    14          SNP        Normal    0
## 313  0.0030000000  20185000 102430696    15      Conumee        Normal    0
## 314 -0.0180000000  20161372  44502266    15          SNP        Normal    0
## 315  0.2050000000  44514571  44777942    15          SNP Amplification    0
## 316 -0.0040000000  44788617 102397317    15          SNP        Normal    0
## 317 -0.0810000000     80000  48165000    16      Conumee        Normal    0
## 318 -0.3090000000  48215000  55040000    16      Conumee      Deletion    0
## 319  0.0300000000  55225000  55885000    16      Conumee        Normal    0
## 320 -0.3250000000  55970000  56715000    16      Conumee      Deletion    0
## 321 -0.0410000000  56745000  57995000    16      Conumee        Normal    0
## 322 -0.3390000000  58020000  90222377    16      Conumee      Deletion    0
## 323  0.0300000000     83887  48175235    16          SNP        Normal    0
## 324 -0.5670000000  48185960  55137655    16          SNP      Deletion    0
## 325  0.0520000000  55156505  55879117    16          SNP        Normal    0
## 326 -0.5860000000  55889730  56698268    16          SNP      Deletion    0
## 327  0.0290000000  56724810  57983711    16          SNP        Normal    0
## 328 -0.5640000000  58011450  90158005    16          SNP      Deletion    0
## 329 -0.0470000000     15000  81122605    17      Conumee        Normal    0
## 330  0.0000000000    400959  80263427    17          SNP        Normal    0
## 331  0.0330000000     45000  78008624    18      Conumee        Normal    0
## 332  0.0010000000     12842  78007784    18          SNP        Normal    0
## 333 -0.1290000000    175000  34880000    19      Conumee        Normal    0
## 334 -0.4130000000  34910000  59099492    19      Conumee      Deletion    0
## 335  0.0100000000    247232  20170214    19          SNP        Normal    0
## 336 -0.3030000000  20179614  20462595    19          SNP      Deletion    0
## 337 -0.0540000000  20473553  34916011    19          SNP        Normal    0
## 338 -0.5750000000  34931904  59093239    19          SNP      Deletion    0
## 339 -0.0220000000    100000  62927760    20      Conumee        Normal    0
## 340 -0.0130000000     69094  62912463    20          SNP        Normal    0
## 341  0.0070000000  10843948  48099948    21      Conumee        Normal    0
## 342  0.0440000000   9648315  48097610    21          SNP        Normal    0
## 343 -0.0470000000  16165000  51212283    22      Conumee        Normal    0
## 344  0.0300000000  16054713  24341388    22          SNP        Normal    0
## 345  0.6420000000  24346428  24390318    22          SNP Amplification    0
## 346  0.0210000000  24394088  51213826    22          SNP        Normal    0

A reasonable contest would be that this data has a lot of duplications. Further processing actually eliminates this in the analytical functions, as they all contain unique filter functions to ENSURE this doesn’t happen.

GenomeModified(df)  # We calculate how much of the genome is modified.
## [1] 54.11321
GenomicIndex(df, T)  # Calculates the GI for the selected dataframe
## [1] 240.1
# An inherent limitation of this function is that it does
# one case at a time, else the # statistics break

suppressWarnings({

    print("MethylMasteR")
    print(fpCheck(labLMSProc(9202, "MethylMaster", 10000)))
    print("SeSAMe")
    print(fpCheck(labLMSProc(9202, "Sesame", 10000)))
    print("Conumee")
    print(fpCheck(labLMSProc(9202, "Conumee", 10000)))

})
## [1] "MethylMasteR"
## [[1]]
##    Chromosome Genome_bp     TP_bp   FP_bp    FN_bp    CNV_bp    TN_bp  Accuracy
## 1           1 249250621 148673726       0 98364708 247038434  2212187 0.6053582
## 2           2 243199373 241125736       0        0 241125736  2073637 1.0000000
## 3           3 198022430 197737565       0        0 197737565   284865 1.0000000
## 4           4 191154276 189336897       0   549470 189886367  1267909 0.9971255
## 5           5 180915260 180237074       0   376689 180613763   301497 0.9979179
## 6           6 171115067 170458082       0        0 170458082   656985 1.0000000
## 7           7 159138663 159068444       0        0 159068444    70219 1.0000000
## 8           8 146364022 144558938       0   243707 144802645  1561377 0.9983349
## 9           9 141213431 137648465       0   308128 137956593  3256838 0.9978180
## 10         10 135534747 131626829 1668262        0 133295091  2239656 0.9876913
## 11         11 135006516 134616085   80001        0 134696086   310430 0.9994074
## 12         12 133851895 133033256       0        0 133033256   818639 1.0000000
## 13         13 115169878  92723951  424662   566961  93715574 21454304 0.9913899
## 14         14 107349540  85461659  413216   441110  86315985 21033555 0.9920416
## 15         15 102531392  81331967       0   263372  81595339 20936053 0.9974313
## 16         16  90354753  89351150   20427        0  89371577   983176 0.9997739
## 17         17  81195210  79767471       0        0  79767471  1427739 1.0000000
## 18         18  78077248  77872785       0        0  77872785   204463 1.0000000
## 19         19  59128983  57291338  461012   282982  58035332  1093651 0.9874174
## 20         20  63025520  62734296       0        0  62734296   291224 1.0000000
## 21         21  48129895  36110549       0        0  36110549 12019346 1.0000000
## 22         22  51304566  34149531       0    43891  34193422 17111144 0.9991445
##    CNV_Only_Accuracy
## 1          0.6018243
## 2          1.0000000
## 3          1.0000000
## 4          0.9971063
## 5          0.9979144
## 6          1.0000000
## 7          1.0000000
## 8          0.9983170
## 9          0.9977665
## 10         0.9874844
## 11         0.9994061
## 12         1.0000000
## 13         0.9894188
## 14         0.9901023
## 15         0.9967722
## 16         0.9997714
## 17         1.0000000
## 18         1.0000000
## 19         0.9871803
## 20         1.0000000
## 21         1.0000000
## 22         0.9987164
## 
## [[2]]
## [1] 0.9795842
## 
## [1] "SeSAMe"
## [[1]]
##    Chromosome Genome_bp     TP_bp   FP_bp     FN_bp    CNV_bp    TN_bp
## 1           1 249250621 107865408       0 138999562 246864970  2385651
## 2           2 243199373   2729497       0 238396239 241125736  2073637
## 3           3 198022430 197737565       0         0 197737565   284865
## 4           4 191154276 189336897       0    590066 189926963  1227313
## 5           5 180915260 180237074       0    376689 180613763   301497
## 6           6 171115067 170458082       0         0 170458082   656985
## 7           7 159138663 159068444       0         0 159068444    70219
## 8           8 146364022 144581521       0    243707 144825228  1538794
## 9           9 141213431 137698727       0    308128 138006855  3206576
## 10         10 135534747  75957193       0  57337898 133295091  2239656
## 11         11 135006516 134746084       0         0 134746084   260432
## 12         12 133851895 133033256       0         0 133033256   818639
## 13         13 115169878  79256856       0  14623718  93880574 21289304
## 14         14 107349540  85506659  413216    441110  86360985 20988555
## 15         15 102531392  79020125 1907001    263372  81190498 21340894
## 16         16  90354753  49651543       0  39728866  89380409   974344
## 17         17  81195210  79767471       0         0  79767471  1427739
## 18         18  78077248  77927785       0         0  77927785   149463
## 19         19  59128983  57191340  461012    282982  57935334  1193649
## 20         20  63025520  62734296       0         0  62734296   291224
## 21         21  48129895  37031678       0         0  37031678 11098217
## 22         22  51304566  34661823       0     43891  34705714 16598852
##      Accuracy CNV_Only_Accuracy
## 1  0.44233013        0.43694092
## 2  0.01974978        0.01131981
## 3  1.00000000        1.00000000
## 4  0.99691314        0.99689320
## 5  0.99791787        0.99791439
## 6  1.00000000        1.00000000
## 7  1.00000000        1.00000000
## 8  0.99833493        0.99831723
## 9  0.99781800        0.99776730
## 10 0.57695057        0.56984239
## 11 1.00000000        1.00000000
## 12 1.00000000        1.00000000
## 13 0.87302480        0.84423063
## 14 0.99204164        0.99010750
## 15 0.97883211        0.97326814
## 16 0.56030132        0.55550812
## 17 1.00000000        1.00000000
## 18 1.00000000        1.00000000
## 19 0.98741744        0.98715820
## 20 1.00000000        1.00000000
## 21 1.00000000        1.00000000
## 22 0.99914450        0.99873534
## 
## [[2]]
## [1] 0.8827626
## 
## [1] "Conumee"
## [[1]]
##    Chromosome Genome_bp     TP_bp FP_bp    FN_bp    CNV_bp    TN_bp  Accuracy
## 1           1 249250621 151524732 65053 95644747 247234532  2016089 0.6160098
## 2           2 243199373 242371241     0        0 242371241   828132 1.0000000
## 3           3 198022430 197702565     0        0 197702565   319865 1.0000000
## 4           4 191154276 190185986     0   590066 190776052   378224 0.9969131
## 5           5 180915260 180248935     0   376689 180625624   289636 0.9979179
## 6           6 171115067 170708143     0        0 170708143   406924 1.0000000
## 7           7 159138663 159002912     0        0 159002912   135751 1.0000000
## 8           8 146364022 145809214     0   243707 146052921   311101 0.9983349
## 9           9 141213431 140526129     0   308128 140834257   379174 0.9978180
## 10         10 135534747 135203235     0        0 135203235   331512 1.0000000
## 11         11 135006516 134700495     0        0 134700495   306021 1.0000000
## 12         12 133851895 133606549     0        0 133606549   245346 1.0000000
## 13         13 115169878  94869942     0        0  94869942 20299936 1.0000000
## 14         14 107349540  86744975     0    97618  86842593 20506947 0.9990907
## 15         15 102531392  81925968     0   263372  82189340 20342052 0.9974313
## 16         16  90354753  89665220     0        0  89665220   689533 1.0000000
## 17         17  81195210  79862469     0        0  79862469  1332741 1.0000000
## 18         18  78077248  77962785     0        0  77962785   114463 1.0000000
## 19         19  59128983  58490767  6012   282982  58779761   349222 0.9951125
## 20         20  63025520  62812464     0        0  62812464   213056 1.0000000
## 21         21  48129895  37253663     0        0  37253663 10876232 1.0000000
## 22         22  51304566  34994585     0    43891  35038476 16266090 0.9991445
##    CNV_Only_Accuracy
## 1          0.6128785
## 2          1.0000000
## 3          1.0000000
## 4          0.9969070
## 5          0.9979145
## 6          1.0000000
## 7          1.0000000
## 8          0.9983314
## 9          0.9978121
## 10         1.0000000
## 11         1.0000000
## 12         1.0000000
## 13         1.0000000
## 14         0.9988759
## 15         0.9967955
## 16         1.0000000
## 17         1.0000000
## 18         1.0000000
## 19         0.9950834
## 20         1.0000000
## 21         1.0000000
## 22         0.9987473
## 
## [[2]]
## [1] 0.9817169

I am not running the full processing again as it is clearly visible how large the system is. Also, it works more like a black-box, so the graph kinda pops out of the code.

# Looking for concordance
genes <- names(ap)
bins <- c("50000", "10000", "1e+05", "1e+06")
states <- c("Conumee – default bin size", "Conumee – 10kb",
    "Conumee – 100kb", "Conumee – 1Mb", "Sesame – default bin size",
    "Sesame – 10kb", "Sesame – 100kb", "Sesame – 1Mb",
    "MethylMasteR – default bin size", "MethylMasteR – 10kb",
    "MethylMasteR – 100kb", "MethylMasteR – 1Mb")

CCNE1 <- c(1:length(states))
CDKN2A <- c(1:length(states))
MYC <- c(1:length(states))
MYOCD <- c(1:length(states))
PTEN <- c(1:length(states))
RB1 <- c(1:length(states))
TP53 <- c(1:length(states))

output.df <- data.frame(states, CCNE1, CDKN2A, MYC, MYOCD, PTEN,
    RB1, TP53)
for (i in seq_along(ap)) {
    for (j in bins) {
        print(genes[i])
        print(j)
        Methyl <- ap[[i]][[j]] %>%
            dplyr::filter(type == "Gene_MMasteR") %>%
            dplyr::mutate(seg.mean = as.numeric(seg.mean))
        Ses <- ap[[i]][[j]] %>%
            dplyr::filter(type == "Gene_SeSAMe") %>%
            dplyr::mutate(seg.mean = as.numeric(seg.mean))
        Con <- ap[[i]][[j]] %>%
            dplyr::filter(type == "Gene_Conumee") %>%
            dplyr::mutate(seg.mean = as.numeric(seg.mean))
        Snp <- ap[[i]][[j]] %>%
            dplyr::filter(type == "Gene_SNP") %>%
            dplyr::mutate(seg.mean = as.numeric(seg.mean))
        Snp <- Snp %>%
            group_by(case) %>%
            summarize(log2ratio = mean(seg.mean))
        mCorr <- cor(Methyl$seg.mean, Snp$log2ratio)
        sCorr <- cor(Ses$seg.mean, Snp$log2ratio)
        cCorr <- cor(Con$seg.mean, Snp$log2ratio)
        print(paste0(mCorr, " ", sCorr, " ", cCorr))
        tag <- 0
        if (j == "50000") {
            tag <- 1
        }
        if (j == "10000") {
            tag <- 2
        }
        if (j == "1e+05") {
            tag <- 3
        }
        if (j == "1e+06") {
            tag <- 4
        }

        output.df[tag, i + 1] <- mCorr
        output.df[tag + 4, i + 1] <- sCorr
        output.df[tag + 8, i + 1] <- cCorr
    }
}
## [1] "CCNE1"
## [1] "50000"
## [1] "0.826417880352618 0.813440323796319 0.845943210618849"
## [1] "CCNE1"
## [1] "10000"
## [1] "0.849134403884159 0.836896340412142 0.844368393910045"
## [1] "CCNE1"
## [1] "1e+05"
## [1] "0.843005346823355 0.829474876393488 0.831894387147325"
## [1] "CCNE1"
## [1] "1e+06"
## [1] "0.79489252657153 0.805152583360047 0.845781813166039"
## [1] "CDKN2A"
## [1] "50000"
## [1] "0.770286775383964 0.824711869003358 0.820810622368492"
## [1] "CDKN2A"
## [1] "10000"
## [1] "0.784476652907735 0.842870595760608 0.837815008814301"
## [1] "CDKN2A"
## [1] "1e+05"
## [1] "0.828431908549295 0.863729216325694 0.814386084893461"
## [1] "CDKN2A"
## [1] "1e+06"
## [1] "0.776951840796653 0.809258743289404 0.843185857302898"
## [1] "MYC"
## [1] "50000"
## [1] "0.550119920847339 0.533111942514943 0.623517986495779"
## [1] "MYC"
## [1] "10000"
## [1] "0.594882099031743 0.513851869692022 0.379050348014905"
## [1] "MYC"
## [1] "1e+05"
## [1] "0.728429963922226 0.590602707782826 0.616991728990406"
## [1] "MYC"
## [1] "1e+06"
## [1] "0.599560636492384 0.493157855491004 0.613060168297233"
## [1] "MYOCD"
## [1] "50000"
## [1] "0.703082777869045 0.737155429945174 0.757266803619211"
## [1] "MYOCD"
## [1] "10000"
## [1] "0.759241487110125 0.721856082001065 0.743062822010953"
## [1] "MYOCD"
## [1] "1e+05"
## [1] "0.788779978335249 0.738024751153176 0.744233670582984"
## [1] "MYOCD"
## [1] "1e+06"
## [1] "0.737604178197128 0.736457605970674 0.755436379247107"
## [1] "PTEN"
## [1] "50000"
## [1] "0.173994453322823 0.201614441620541 0.158087271330171"
## [1] "PTEN"
## [1] "10000"
## [1] "0.183646163979431 0.212871187889706 0.0466493488085179"
## [1] "PTEN"
## [1] "1e+05"
## [1] "0.156183661438954 0.212959236115107 0.174572305471204"
## [1] "PTEN"
## [1] "1e+06"
## [1] "-0.00562029336073261 0.0525883803472474 0.00346858286312494"
## [1] "RB1"
## [1] "50000"
## [1] "0.284964544161419 -0.103117646873573 0.55669826414135"
## [1] "RB1"
## [1] "10000"
## [1] "0.273210786726921 0.0727401864100489 0.409547861912897"
## [1] "RB1"
## [1] "1e+05"
## [1] "0.444760905459316 -0.022745446473997 0.34792966700185"
## [1] "RB1"
## [1] "1e+06"
## [1] "0.395649026750018 0.328853019174688 0.689928235069948"
## [1] "TP53"
## [1] "50000"
## [1] "0.92032642794316 0.895923294419126 0.889208352500564"
## [1] "TP53"
## [1] "10000"
## [1] "0.91015423233901 0.887451563223858 0.831874713823817"
## [1] "TP53"
## [1] "1e+05"
## [1] "0.925389940484122 0.898103823567314 0.894178403267808"
## [1] "TP53"
## [1] "1e+06"
## [1] "0.838169101292533 0.911586067526427 0.898609062298142"
# Melt to long format
df_long <- melt(output.df, id.vars = "states", variable.name = "gene",
    value.name = "correlation")

# Keep row order
df_long$states <- factor(df_long$states, levels = rev(output.df$states))

# Plot
p <- ggplot(df_long, aes(x = gene, y = states, fill = correlation)) +
    geom_tile(color = "black", linewidth = 0.5) + geom_text(aes(label = sprintf("%.2f",
    correlation)), size = 3, color = "black") + scale_fill_gradient2(low = "#2166ac",
    mid = "#f7f7f7", high = "#50C878", midpoint = 0.5, limits = c(min(df_long$correlation),
        1), name = "Correlation") + labs(title = "CNV Method Comparison by Gene",
    x = "Gene", y = "Method & Bin Size") + theme_minimal(base_size = 12) +
    theme(plot.title = element_text(hjust = 0.5, face = "bold",
        size = 14), axis.text.x = element_text(angle = 30, hjust = 1,
        face = "bold"), axis.text.y = element_text(size = 9),
        panel.grid = element_blank(), legend.position = "right")
p

I just ran the visualizer, as that is the meat of the code.

Finally, we need to plot the final dataset for the case.

Gene <- c("MYC", "MYOCD", "CCNE1", "CDKN2A", "PTEN", "RB1", "TP53")
geneAnno(Gene = Gene, db = df)
## [1] "is here"
##    chrom loc.start   loc.end    seg.mean         type CNVStatus  Gene
## 1      8 128747765 128753680  0.01271818 Gene_MMasteR    Normal  4609
## 2      8 128747765 128753680 -0.02500000     Gene_SNP    Normal  4609
## 3      9  21967751  21994490 -0.02648182 Gene_MMasteR    Normal  1029
## 4      9  21967751  21994490 -0.04800000     Gene_SNP    Normal  1029
## 5     10  89623195  89728532 -0.34798182 Gene_MMasteR  Deletion  5728
## 6     10  89623195  89728532 -0.58100000     Gene_SNP  Deletion  5728
## 7     13  48877883  49056026 -0.32668182 Gene_MMasteR  Deletion  5925
## 8     13  48877883  49056026 -0.54700000     Gene_SNP  Deletion  5925
## 9     17   7565097   7590868 -0.07078182 Gene_MMasteR    Normal  7157
## 10    17  12569207  12670651 -0.07078182 Gene_MMasteR    Normal 93649
## 11    17   7565097   7590868  0.00000000     Gene_SNP    Normal  7157
## 12    17  12569207  12670651  0.00000000     Gene_SNP    Normal 93649
## 13    19  30302901  30315215  0.05271818 Gene_MMasteR    Normal   898
## 14    19  30302901  30315215 -0.05400000     Gene_SNP    Normal   898
## 15     8 128747765 128753680  0.07010000  Gene_SeSAMe    Normal  4609
## 16     9  21967751  21994490  0.03360000  Gene_SeSAMe    Normal  1029
## 17    10  89623195  89728532 -0.29000000  Gene_SeSAMe    Normal  5728
## 18    13  48877883  49056026 -0.27050000  Gene_SeSAMe    Normal  5925
## 19    17   7565097   7590868 -0.01070000  Gene_SeSAMe    Normal  7157
## 20    17  12569207  12670651 -0.01070000  Gene_SeSAMe    Normal 93649
## 21    19  30302901  30315215  0.10900000  Gene_SeSAMe    Normal   898
## 22     8 128747765 128753680  0.02600000 Gene_Conumee    Normal  4609
## 23     9  21967751  21994490 -0.01600000 Gene_Conumee    Normal  1029
## 24    10  89623195  89728532 -0.30200000 Gene_Conumee  Deletion  5728
## 25    13  48877883  49056026 -0.26100000 Gene_Conumee  Deletion  5925
## 26    17   7565097   7590868 -0.04700000 Gene_Conumee    Normal  7157
## 27    17  12569207  12670651 -0.04700000 Gene_Conumee    Normal 93649
## 28    19  30302901  30315215 -0.12900000 Gene_Conumee    Normal   898
## [1] "Gene_MMasteR" "Gene_SNP"     "Gene_SeSAMe"  "Gene_Conumee"
##                     4609        1029       5728       5925        7157
## Gene_MMasteR  0.01271818 -0.02648182 -0.3479818 -0.3266818 -0.07078182
## Gene_SNP     -0.02500000 -0.04800000 -0.5810000 -0.5470000  0.00000000
## Gene_SeSAMe   0.07010000  0.03360000 -0.2900000 -0.2705000 -0.01070000
## Gene_Conumee  0.02600000 -0.01600000 -0.3020000 -0.2610000 -0.04700000
##                    93649         898
## Gene_MMasteR -0.07078182  0.05271818
## Gene_SNP      0.00000000 -0.05400000
## Gene_SeSAMe  -0.01070000  0.10900000
## Gene_Conumee -0.04700000 -0.12900000

## # A tibble: 22 × 4
##    chrom   chr_len  chr_start     chr_mid
##    <dbl>     <dbl>      <dbl>       <dbl>
##  1     1 249220311          0  124610156.
##  2     2 243052331  249220311  370746476.
##  3     3 198172780  492272642  591359032 
##  4     4 190992138  690445422  785941491 
##  5     5 181369130  881437560  972122125 
##  6     6 170977534 1062806690 1148295457 
##  7     7 159247987 1233784224 1313408218.
##  8     8 146292734 1393032211 1466178578 
##  9     9 141081716 1539324945 1609865803 
## 10    10 135482374 1680406661 1748147848 
## # ℹ 12 more rows
##  [1] "chr1"  "chr2"  "chr3"  "chr4"  "chr5"  "chr6"  "chr7"  "chr8"  "chr9" 
## [10] "chr10" "chr11" "chr12" "chr13" "chr14" "chr15" "chr16" "chr17" "chr18"
## [19] "chr19" "chr20" "chr21" "chr22"
##          seg.mean loc.start   loc.end chrom         type     CNVStatus  Gene
## 1   -0.3180000000     93709  39040000     1      Conumee      Deletion     0
## 2   -0.3008000000    677994  16510000     1       SeSAMe      Deletion     0
## 3   -0.3777818159    747994  28115000     1 MethylMaster      Deletion     0
## 4   -0.5230000000    754192  39046130     1          SNP      Deletion     0
## 5    0.0215000000  16570000  16779582     1       SeSAMe        Normal     0
## 6   -0.3448000000  16869582  28185000     1       SeSAMe      Deletion     0
## 7   -0.7534818159  28185000  28505000     1 MethylMaster      Deletion     0
## 8   -0.6069000000  28275000  28695000     1       SeSAMe      Deletion     0
## 9   -0.4224818159  28530000  38525000     1 MethylMaster      Deletion     0
## 10  -0.3593000000  28795000  38525000     1       SeSAMe      Deletion     0
## 11   0.1562181841  38690000 186405000     1 MethylMaster        Normal     0
## 12   0.2126000000  38690000 186405000     1       SeSAMe        Normal     0
## 13   0.3290000000  39053684  71837405     1          SNP Amplification     0
## 14   0.1910000000  39115000  93105000     1      Conumee        Normal     0
## 15   0.5860000000  71858457  72654730     1          SNP Amplification     0
## 16   0.3720000000  72662685  76640953     1          SNP Amplification     0
## 17  -0.0230000000  76658494  77726109     1          SNP        Normal     0
## 18   0.3400000000  77737217  93047956     1          SNP Amplification     0
## 19   0.0030000000  93073228  98750052     1          SNP        Normal     0
## 20   0.0430000000  93270000  98515000     1      Conumee        Normal     0
## 21   0.2900000000  98685000 100545000     1      Conumee Amplification     0
## 22   0.3250000000  98766448 100543962     1          SNP Amplification     0
## 23  -0.0280000000 100549400 110221639     1          SNP        Normal     0
## 24   0.0330000000 100595000 110285000     1      Conumee        Normal     0
## 25   0.2600000000 110222219 111181086     1          SNP Amplification     0
## 26   0.1820000000 110300000 111505000     1      Conumee        Normal     0
## 27  -0.0210000000 111193595 152411090     1          SNP        Normal     0
## 28   0.0110000000 111595000 152240000     1      Conumee        Normal     0
## 29   0.1900000000 152315000 185705000     1      Conumee        Normal     0
## 30   0.3470000000 152411813 208551533     1          SNP Amplification     0
## 31   0.3630000000 185820000 199735000     1      Conumee Amplification     0
## 32   0.3858181841 186560000 199570000     1 MethylMaster Amplification     0
## 33   0.4444000000 186560000 199570000     1       SeSAMe Amplification     0
## 34   0.1513181841 199885000 208295000     1 MethylMaster        Normal     0
## 35   0.2130000000 199885000 208295000     1       SeSAMe        Normal     0
## 36   0.1580000000 199910000 208510000     1      Conumee        Normal     0
## 37  -0.3127818159 208480000 248923211     1 MethylMaster      Deletion     0
## 38  -0.2521000000 208480000 248923211     1       SeSAMe        Normal     0
## 39  -0.5640000000 208569475 249212878     1          SNP      Deletion     0
## 40  -0.2790000000 208690000 249220311     1      Conumee      Deletion     0
## 41  -0.5260000000     21494  47051551     2          SNP      Deletion     0
## 42  -0.2890000000     30000  47050000     2      Conumee      Deletion     0
## 43  -0.3056818159    110000  46830000     2 MethylMaster      Deletion     0
## 44  -0.2467000000    110000  46830000     2       SeSAMe        Normal     0
## 45  -1.3103818159  46880000  49160000     2 MethylMaster      Deletion     0
## 46  -1.2535000000  46880000  49160000     2       SeSAMe      Deletion     0
## 47  -1.6880000000  47067057  49997218     2          SNP      Deletion     0
## 48  -1.2360000000  47095000  49795000     2      Conumee      Deletion     0
## 49  -0.3053818159  49835000 200815000     2 MethylMaster      Deletion     0
## 50  -0.2428000000  49835000 200815000     2       SeSAMe        Normal     0
## 51  -0.5610000000  50007748 243052331     2          SNP      Deletion     0
## 52  -0.2900000000  50395000 243046238     2      Conumee      Deletion     0
## 53  -0.5376818159 200840000 201305000     2 MethylMaster      Deletion     0
## 54  -0.4734000000 200840000 201305000     2       SeSAMe      Deletion     0
## 55  -0.3142818159 201405000 242111765     2 MethylMaster      Deletion     0
## 56  -0.2557000000 201405000 242111765     2       SeSAMe        Normal     0
## 57  -0.0690000000     63411 197852564     3          SNP        Normal     0
## 58   0.0185181841    115000 198097780     3 MethylMaster        Normal     0
## 59   0.0762000000    115000 198172780     3       SeSAMe        Normal     0
## 60   0.0200000000    150000 197881215     3      Conumee        Normal     0
## 61   0.0500000000     35000 190992138     4      Conumee        Normal     0
## 62   0.1150000000     65000 190066561     4       SeSAMe        Normal     0
## 63  -0.5940000000     69404    334213     4          SNP      Deletion     0
## 64   0.0581181841    110000 190066561     4 MethylMaster        Normal     0
## 65  -0.0470000000    360026 180023290     4          SNP        Normal     0
## 66  -0.4110000000 180040368 180365623     4          SNP      Deletion     0
## 67  -0.0540000000 180392930 190915650     4          SNP        Normal     0
## 68   0.0460000000     35000 180797630     5      Conumee        Normal     0
## 69  -0.0080000000     38139    392863     5          SNP        Normal     0
## 70   0.0446181841     50000 181369130     5 MethylMaster        Normal     0
## 71   0.1023000000     50000 181369130     5       SeSAMe        Normal     0
## 72   0.2300000000    412226    788914     5          SNP Amplification     0
## 73  -0.0070000000    804103 180698312     5          SNP        Normal     0
## 74   0.0250000000    130000 170977534     6      Conumee        Normal     0
## 75  -0.0131818159    140000 170662990     6 MethylMaster        Normal     0
## 76   0.0438000000    140000 170662990     6       SeSAMe        Normal     0
## 77  -0.0320000000    204909 170913051     6          SNP        Normal     0
## 78  -0.3160000000     40000 159044332     7      Conumee      Deletion     0
## 79  -0.5470000000     41421 159118443     7          SNP      Deletion     0
## 80  -0.3608818159     50000 159247987     7 MethylMaster      Deletion     0
## 81  -0.3015000000     50000 159247987     7       SeSAMe      Deletion     0
## 82   0.0260000000     95000 146267011     8      Conumee        Normal     0
## 83   0.0701000000    160000 145039318     8       SeSAMe        Normal     0
## 84  -0.0200000000    172417  39194984     8          SNP        Normal     0
## 85   0.0127181841    195000 145039318     8 MethylMaster        Normal     0
## 86  -1.6230000000  39217074  39460780     8          SNP      Deletion     0
## 87  -0.0250000000  39480366 146292734     8          SNP        Normal     0
## 88   0.0127181841 128747765 128753680     8 Gene_MMasteR        Normal  4609
## 89  -0.0250000000 128747765 128753680     8     Gene_SNP        Normal  4609
## 90   0.0701000000 128747765 128753680     8  Gene_SeSAMe        Normal  4609
## 91   0.0260000000 128747765 128753680     8 Gene_Conumee        Normal  4609
## 92   0.0336000000    110000 138227359     9       SeSAMe        Normal     0
## 93  -0.0160000000    110000 141081716     9      Conumee        Normal     0
## 94  -0.0240000000    204738   5021738     9          SNP        Normal     0
## 95  -0.0264818159    215000 138187359     9 MethylMaster        Normal     0
## 96  -0.2510000000   5023689   5069837     9          SNP      Deletion     0
## 97  -0.0480000000   5071049 129580187     9          SNP        Normal     0
## 98  -0.0264818159  21967751  21994490     9 Gene_MMasteR        Normal  1029
## 99  -0.0480000000  21967751  21994490     9     Gene_SNP        Normal  1029
## 100  0.0336000000  21967751  21994490     9  Gene_SeSAMe        Normal  1029
## 101 -0.0160000000  21967751  21994490     9 Gene_Conumee        Normal  1029
## 102 -0.2400000000 129582563 129844541     9          SNP      Deletion     0
## 103  0.0000000000 129854773 141054761     9          SNP        Normal     0
## 104  0.0729000000     70000  74415000    10       SeSAMe        Normal     0
## 105  0.0060000000     80000  76205000    10      Conumee        Normal     0
## 106  0.0141181841    125000  74415000    10 MethylMaster        Normal     0
## 107 -0.0340000000    126070  76263261    10          SNP        Normal     0
## 108 -0.3479818159  74595000 133625233    10 MethylMaster      Deletion     0
## 109 -0.2900000000  74595000 133625233    10       SeSAMe        Normal     0
## 110 -0.5810000000  76287336 135434303    10          SNP      Deletion     0
## 111 -0.3020000000  76310000 135482374    10      Conumee      Deletion     0
## 112 -0.3479818159  89623195  89728532    10 Gene_MMasteR      Deletion  5728
## 113 -0.5810000000  89623195  89728532    10     Gene_SNP      Deletion  5728
## 114 -0.2900000000  89623195  89728532    10  Gene_SeSAMe        Normal  5728
## 115 -0.3020000000  89623195  89728532    10 Gene_Conumee      Deletion  5728
## 116  0.0508000000    130000 135013311    11       SeSAMe        Normal     0
## 117  0.0090000000    130000 134893258    11      Conumee        Normal     0
## 118 -0.0006818159    145000  62735000    11 MethylMaster        Normal     0
## 119 -0.0150000000    192764 134938847    11          SNP        Normal     0
## 120 -0.3424818159  62760000  62840000    11 MethylMaster      Deletion     0
## 121 -0.0074818159  62865000 134993311    11 MethylMaster        Normal     0
## 122  0.0600000000     55000 133222655    12       SeSAMe        Normal     0
## 123  0.0027181841     70000 133222655    12 MethylMaster        Normal     0
## 124  0.0020000000    182870 133795948    12      Conumee        Normal     0
## 125 -0.0310000000    189400 133818115    12          SNP        Normal     0
## 126  0.1000000000  18639053  47270000    13       SeSAMe        Normal     0
## 127  0.0403181841  18679053  47270000    13 MethylMaster        Normal     0
## 128 -0.0190000000  19084823  48054661    13          SNP        Normal     0
## 129  0.0290000000  19100000  47985000    13      Conumee        Normal     0
## 130 -0.3266818159  47630000  61950000    13 MethylMaster      Deletion     0
## 131 -0.2705000000  47630000  62140000    13       SeSAMe        Normal     0
## 132 -0.5470000000  48058244  63661960    13          SNP      Deletion     0
## 133 -0.2610000000  48350000  63100000    13      Conumee      Deletion     0
## 134 -0.3266818159  48877883  49056026    13 Gene_MMasteR      Deletion  5925
## 135 -0.5470000000  48877883  49056026    13     Gene_SNP      Deletion  5925
## 136 -0.2705000000  48877883  49056026    13  Gene_SeSAMe        Normal  5925
## 137 -0.2610000000  48877883  49056026    13 Gene_Conumee      Deletion  5925
## 138  0.0940181841  63095000 114332164    13 MethylMaster        Normal     0
## 139  0.1508000000  63120000 114332164    13       SeSAMe        Normal     0
## 140  0.0190000000  63685149 115103150    13          SNP        Normal     0
## 141  0.0660000000  63860000 115094939    13      Conumee        Normal     0
## 142  0.0794000000  19187179  71035000    14       SeSAMe        Normal     0
## 143  0.0330000000  19210000  71515000    14      Conumee        Normal     0
## 144  0.0220181841  19770857  71035000    14 MethylMaster        Normal     0
## 145 -0.0220000000  20219083  71568215    14          SNP        Normal     0
## 146 -0.3619818159  71155000  90290000    14 MethylMaster      Deletion     0
## 147 -0.3041000000  71155000  90290000    14       SeSAMe      Deletion     0
## 148 -0.6010000000  71580778  90801109    14          SNP      Deletion     0
## 149 -0.3240000000  71610000  73705000    14      Conumee      Deletion     0
## 150 -0.5770000000  73715000  74150000    14      Conumee      Deletion     0
## 151 -0.3150000000  74185000  90760000    14      Conumee      Deletion     0
## 152 -0.0233818159  90360000 106751859    14 MethylMaster        Normal     0
## 153  0.0322000000  90360000 106796859    14       SeSAMe        Normal     0
## 154 -0.0080000000  90795000 107254770    14      Conumee        Normal     0
## 155  0.0170000000  90815342 106836445    14          SNP        Normal     0
## 156 -0.2410000000 106839840 106931347    14          SNP      Deletion     0
## 157 -0.0370000000 106931821 107282024    14          SNP        Normal     0
## 158 -0.3009000000  20062627  22068372    15       SeSAMe      Deletion     0
## 159 -0.0180000000  20161372  44502266    15          SNP        Normal     0
## 160  0.0030000000  20185000 102430696    15      Conumee        Normal     0
## 161 -0.0141818159  20232279 101850595    15 MethylMaster        Normal     0
## 162  0.0452000000  22569121 101875595    15       SeSAMe        Normal     0
## 163  0.2050000000  44514571  44777942    15          SNP Amplification     0
## 164 -0.0040000000  44788617 102397317    15          SNP        Normal     0
## 165 -0.0895818159     40000  48010000    16 MethylMaster        Normal     0
## 166 -0.0305000000     40000  48010000    16       SeSAMe        Normal     0
## 167 -0.0810000000     80000  48165000    16      Conumee        Normal     0
## 168  0.0300000000     83887  48175235    16          SNP        Normal     0
## 169 -0.3532818159  48160000  54995000    16 MethylMaster      Deletion     0
## 170 -0.2948000000  48160000  54995000    16       SeSAMe        Normal     0
## 171 -0.5670000000  48185960  55137655    16          SNP      Deletion     0
## 172 -0.3090000000  48215000  55040000    16      Conumee      Deletion     0
## 173  0.0520000000  55156505  55879117    16          SNP        Normal     0
## 174 -0.0350818159  55185000  55785000    16 MethylMaster        Normal     0
## 175  0.0270000000  55185000  55785000    16       SeSAMe        Normal     0
## 176  0.0300000000  55225000  55885000    16      Conumee        Normal     0
## 177 -0.5860000000  55889730  56698268    16          SNP      Deletion     0
## 178 -0.3510818159  55925000  56730000    16 MethylMaster      Deletion     0
## 179 -0.2897000000  55925000  56730000    16       SeSAMe        Normal     0
## 180 -0.3250000000  55970000  56715000    16      Conumee      Deletion     0
## 181  0.0290000000  56724810  57983711    16          SNP        Normal     0
## 182 -0.0410000000  56745000  57995000    16      Conumee        Normal     0
## 183 -0.0746818159  56820000  57925000    16 MethylMaster        Normal     0
## 184 -0.0154000000  56820000  57925000    16       SeSAMe        Normal     0
## 185 -0.3635818159  57995000  90149173    16 MethylMaster      Deletion     0
## 186 -0.2987000000  57995000  90159173    16       SeSAMe        Normal     0
## 187 -0.5640000000  58011450  90158005    16          SNP      Deletion     0
## 188 -0.3390000000  58020000  90222377    16      Conumee      Deletion     0
## 189 -0.0470000000     15000  81122605    17      Conumee        Normal     0
## 190 -0.0107000000    120000  68480000    17       SeSAMe        Normal     0
## 191 -0.0707818159    130000  68480000    17 MethylMaster        Normal     0
## 192  0.0000000000    400959  80263427    17          SNP        Normal     0
## 193 -0.0707818159   7565097   7590868    17 Gene_MMasteR        Normal  7157
## 194  0.0000000000   7565097   7590868    17     Gene_SNP        Normal  7157
## 195 -0.0107000000   7565097   7590868    17  Gene_SeSAMe        Normal  7157
## 196 -0.0470000000   7565097   7590868    17 Gene_Conumee        Normal  7157
## 197 -0.0707818159  12569207  12670651    17 Gene_MMasteR        Normal 93649
## 198  0.0000000000  12569207  12670651    17     Gene_SNP        Normal 93649
## 199 -0.0107000000  12569207  12670651    17  Gene_SeSAMe        Normal 93649
## 200 -0.0470000000  12569207  12670651    17 Gene_Conumee        Normal 93649
## 201  0.1569181841  68530000  72070000    17 MethylMaster        Normal     0
## 202  0.2163000000  68530000  72070000    17       SeSAMe        Normal     0
## 203 -0.0682818159  72115000  83168721    17 MethylMaster        Normal     0
## 204 -0.0098000000  72115000  83168721    17       SeSAMe        Normal     0
## 205  0.0010000000     12842  78007784    18          SNP        Normal     0
## 206  0.0330000000     45000  78008624    18      Conumee        Normal     0
## 207  0.1163000000     80000  80206643    18       SeSAMe        Normal     0
## 208  0.0574181841    135000  80206643    18 MethylMaster        Normal     0
## 209 -0.1467818159    175000  29890000    19 MethylMaster        Normal     0
## 210 -0.0894000000    175000  29890000    19       SeSAMe        Normal     0
## 211 -0.1290000000    175000  34880000    19      Conumee        Normal     0
## 212  0.0100000000    247232  20170214    19          SNP        Normal     0
## 213 -0.3030000000  20179614  20462595    19          SNP      Deletion     0
## 214 -0.0540000000  20473553  34916011    19          SNP        Normal     0
## 215  0.0527181841  29975000  32370000    19 MethylMaster        Normal     0
## 216  0.1090000000  29975000  32370000    19       SeSAMe        Normal     0
## 217  0.0527181841  30302901  30315215    19 Gene_MMasteR        Normal   898
## 218 -0.0540000000  30302901  30315215    19     Gene_SNP        Normal   898
## 219  0.1090000000  30302901  30315215    19  Gene_SeSAMe        Normal   898
## 220 -0.1290000000  30302901  30315215    19 Gene_Conumee        Normal   898
## 221 -0.1348818159  32490000  34390000    19 MethylMaster        Normal     0
## 222 -0.0719000000  32490000  34390000    19       SeSAMe        Normal     0
## 223 -0.4709818159  34455000  58588808    19 MethylMaster      Deletion     0
## 224 -0.4152000000  34455000  53560000    19       SeSAMe      Deletion     0
## 225 -0.4130000000  34910000  59099492    19      Conumee      Deletion     0
## 226 -0.5750000000  34931904  59093239    19          SNP      Deletion     0
## 227 -0.7416000000  53605000  53765000    19       SeSAMe      Deletion     0
## 228 -0.3768000000  53820000  58588808    19       SeSAMe      Deletion     0
## 229 -0.0130000000     69094  62912463    20          SNP        Normal     0
## 230 -0.0220000000    100000  62927760    20      Conumee        Normal     0
## 231 -0.0246818159    178168  64292084    20 MethylMaster        Normal     0
## 232  0.0340000000    178168  64292084    20       SeSAMe        Normal     0
## 233  0.0914000000   5055000  46679992    21       SeSAMe        Normal     0
## 234  0.0440000000   9648315  48097610    21          SNP        Normal     0
## 235  0.0343181841  10569444  46679992    21 MethylMaster        Normal     0
## 236  0.0070000000  10843948  48099948    21      Conumee        Normal     0
## 237 -0.0092000000  15422159  50769234    22       SeSAMe        Normal     0
## 238  0.0300000000  16054713  24341388    22          SNP        Normal     0
## 239 -0.0470000000  16165000  51212283    22      Conumee        Normal     0
## 240 -0.0662818159  16567005  50769234    22 MethylMaster        Normal     0
## 241  0.6420000000  24346428  24390318    22          SNP Amplification     0
## 242  0.0210000000  24394088  51213826    22          SNP        Normal     0
##     type_group   chr_len  chr_start    chr_mid  start_cum    end_cum
## 1      non-SNP 249220311          0  124610156      93709   39040000
## 2      non-SNP 249220311          0  124610156     677994   16510000
## 3      non-SNP 249220311          0  124610156     747994   28115000
## 4          SNP 249220311          0  124610156     754192   39046130
## 5      non-SNP 249220311          0  124610156   16570000   16779582
## 6      non-SNP 249220311          0  124610156   16869582   28185000
## 7      non-SNP 249220311          0  124610156   28185000   28505000
## 8      non-SNP 249220311          0  124610156   28275000   28695000
## 9      non-SNP 249220311          0  124610156   28530000   38525000
## 10     non-SNP 249220311          0  124610156   28795000   38525000
## 11     non-SNP 249220311          0  124610156   38690000  186405000
## 12     non-SNP 249220311          0  124610156   38690000  186405000
## 13         SNP 249220311          0  124610156   39053684   71837405
## 14     non-SNP 249220311          0  124610156   39115000   93105000
## 15         SNP 249220311          0  124610156   71858457   72654730
## 16         SNP 249220311          0  124610156   72662685   76640953
## 17         SNP 249220311          0  124610156   76658494   77726109
## 18         SNP 249220311          0  124610156   77737217   93047956
## 19         SNP 249220311          0  124610156   93073228   98750052
## 20     non-SNP 249220311          0  124610156   93270000   98515000
## 21     non-SNP 249220311          0  124610156   98685000  100545000
## 22         SNP 249220311          0  124610156   98766448  100543962
## 23         SNP 249220311          0  124610156  100549400  110221639
## 24     non-SNP 249220311          0  124610156  100595000  110285000
## 25         SNP 249220311          0  124610156  110222219  111181086
## 26     non-SNP 249220311          0  124610156  110300000  111505000
## 27         SNP 249220311          0  124610156  111193595  152411090
## 28     non-SNP 249220311          0  124610156  111595000  152240000
## 29     non-SNP 249220311          0  124610156  152315000  185705000
## 30         SNP 249220311          0  124610156  152411813  208551533
## 31     non-SNP 249220311          0  124610156  185820000  199735000
## 32     non-SNP 249220311          0  124610156  186560000  199570000
## 33     non-SNP 249220311          0  124610156  186560000  199570000
## 34     non-SNP 249220311          0  124610156  199885000  208295000
## 35     non-SNP 249220311          0  124610156  199885000  208295000
## 36     non-SNP 249220311          0  124610156  199910000  208510000
## 37     non-SNP 249220311          0  124610156  208480000  248923211
## 38     non-SNP 249220311          0  124610156  208480000  248923211
## 39         SNP 249220311          0  124610156  208569475  249212878
## 40     non-SNP 249220311          0  124610156  208690000  249220311
## 41         SNP 243052331  249220311  370746476  249241805  296271862
## 42     non-SNP 243052331  249220311  370746476  249250311  296270311
## 43     non-SNP 243052331  249220311  370746476  249330311  296050311
## 44     non-SNP 243052331  249220311  370746476  249330311  296050311
## 45     non-SNP 243052331  249220311  370746476  296100311  298380311
## 46     non-SNP 243052331  249220311  370746476  296100311  298380311
## 47         SNP 243052331  249220311  370746476  296287368  299217529
## 48     non-SNP 243052331  249220311  370746476  296315311  299015311
## 49     non-SNP 243052331  249220311  370746476  299055311  450035311
## 50     non-SNP 243052331  249220311  370746476  299055311  450035311
## 51         SNP 243052331  249220311  370746476  299228059  492272642
## 52     non-SNP 243052331  249220311  370746476  299615311  492266549
## 53     non-SNP 243052331  249220311  370746476  450060311  450525311
## 54     non-SNP 243052331  249220311  370746476  450060311  450525311
## 55     non-SNP 243052331  249220311  370746476  450625311  491332076
## 56     non-SNP 243052331  249220311  370746476  450625311  491332076
## 57         SNP 198172780  492272642  591359032  492336053  690125206
## 58     non-SNP 198172780  492272642  591359032  492387642  690370422
## 59     non-SNP 198172780  492272642  591359032  492387642  690445422
## 60     non-SNP 198172780  492272642  591359032  492422642  690153857
## 61     non-SNP 190992138  690445422  785941491  690480422  881437560
## 62     non-SNP 190992138  690445422  785941491  690510422  880511983
## 63         SNP 190992138  690445422  785941491  690514826  690779635
## 64     non-SNP 190992138  690445422  785941491  690555422  880511983
## 65         SNP 190992138  690445422  785941491  690805448  870468712
## 66         SNP 190992138  690445422  785941491  870485790  870811045
## 67         SNP 190992138  690445422  785941491  870838352  881361072
## 68     non-SNP 181369130  881437560  972122125  881472560 1062235190
## 69         SNP 181369130  881437560  972122125  881475699  881830423
## 70     non-SNP 181369130  881437560  972122125  881487560 1062806690
## 71     non-SNP 181369130  881437560  972122125  881487560 1062806690
## 72         SNP 181369130  881437560  972122125  881849786  882226474
## 73         SNP 181369130  881437560  972122125  882241663 1062135872
## 74     non-SNP 170977534 1062806690 1148295457 1062936690 1233784224
## 75     non-SNP 170977534 1062806690 1148295457 1062946690 1233469680
## 76     non-SNP 170977534 1062806690 1148295457 1062946690 1233469680
## 77         SNP 170977534 1062806690 1148295457 1063011599 1233719741
## 78     non-SNP 159247987 1233784224 1313408218 1233824224 1392828556
## 79         SNP 159247987 1233784224 1313408218 1233825645 1392902667
## 80     non-SNP 159247987 1233784224 1313408218 1233834224 1393032211
## 81     non-SNP 159247987 1233784224 1313408218 1233834224 1393032211
## 82     non-SNP 146292734 1393032211 1466178578 1393127211 1539299222
## 83     non-SNP 146292734 1393032211 1466178578 1393192211 1538071529
## 84         SNP 146292734 1393032211 1466178578 1393204628 1432227195
## 85     non-SNP 146292734 1393032211 1466178578 1393227211 1538071529
## 86         SNP 146292734 1393032211 1466178578 1432249285 1432492991
## 87         SNP 146292734 1393032211 1466178578 1432512577 1539324945
## 88     non-SNP 146292734 1393032211 1466178578 1521779976 1521785891
## 89     non-SNP 146292734 1393032211 1466178578 1521779976 1521785891
## 90     non-SNP 146292734 1393032211 1466178578 1521779976 1521785891
## 91     non-SNP 146292734 1393032211 1466178578 1521779976 1521785891
## 92     non-SNP 141081716 1539324945 1609865803 1539434945 1677552304
## 93     non-SNP 141081716 1539324945 1609865803 1539434945 1680406661
## 94         SNP 141081716 1539324945 1609865803 1539529683 1544346683
## 95     non-SNP 141081716 1539324945 1609865803 1539539945 1677512304
## 96         SNP 141081716 1539324945 1609865803 1544348634 1544394782
## 97         SNP 141081716 1539324945 1609865803 1544395994 1668905132
## 98     non-SNP 141081716 1539324945 1609865803 1561292696 1561319435
## 99     non-SNP 141081716 1539324945 1609865803 1561292696 1561319435
## 100    non-SNP 141081716 1539324945 1609865803 1561292696 1561319435
## 101    non-SNP 141081716 1539324945 1609865803 1561292696 1561319435
## 102        SNP 141081716 1539324945 1609865803 1668907508 1669169486
## 103        SNP 141081716 1539324945 1609865803 1669179718 1680379706
## 104    non-SNP 135482374 1680406661 1748147848 1680476661 1754821661
## 105    non-SNP 135482374 1680406661 1748147848 1680486661 1756611661
## 106    non-SNP 135482374 1680406661 1748147848 1680531661 1754821661
## 107        SNP 135482374 1680406661 1748147848 1680532731 1756669922
## 108    non-SNP 135482374 1680406661 1748147848 1755001661 1814031894
## 109    non-SNP 135482374 1680406661 1748147848 1755001661 1814031894
## 110        SNP 135482374 1680406661 1748147848 1756693997 1815840964
## 111    non-SNP 135482374 1680406661 1748147848 1756716661 1815889035
## 112    non-SNP 135482374 1680406661 1748147848 1770029856 1770135193
## 113    non-SNP 135482374 1680406661 1748147848 1770029856 1770135193
## 114    non-SNP 135482374 1680406661 1748147848 1770029856 1770135193
## 115    non-SNP 135482374 1680406661 1748147848 1770029856 1770135193
## 116    non-SNP 135013311 1815889035 1883395690 1816019035 1950902346
## 117    non-SNP 135013311 1815889035 1883395690 1816019035 1950782293
## 118    non-SNP 135013311 1815889035 1883395690 1816034035 1878624035
## 119        SNP 135013311 1815889035 1883395690 1816081799 1950827882
## 120    non-SNP 135013311 1815889035 1883395690 1878649035 1878729035
## 121    non-SNP 135013311 1815889035 1883395690 1878754035 1950882346
## 122    non-SNP 133818115 1950902346 2017811404 1950957346 2084125001
## 123    non-SNP 133818115 1950902346 2017811404 1950972346 2084125001
## 124    non-SNP 133818115 1950902346 2017811404 1951085216 2084698294
## 125        SNP 133818115 1950902346 2017811404 1951091746 2084720461
## 126    non-SNP 115103150 2084720461 2142272036 2103359514 2131990461
## 127    non-SNP 115103150 2084720461 2142272036 2103399514 2131990461
## 128        SNP 115103150 2084720461 2142272036 2103805284 2132775122
## 129    non-SNP 115103150 2084720461 2142272036 2103820461 2132705461
## 130    non-SNP 115103150 2084720461 2142272036 2132350461 2146670461
## 131    non-SNP 115103150 2084720461 2142272036 2132350461 2146860461
## 132        SNP 115103150 2084720461 2142272036 2132778705 2148382421
## 133    non-SNP 115103150 2084720461 2142272036 2133070461 2147820461
## 134    non-SNP 115103150 2084720461 2142272036 2133598344 2133776487
## 135    non-SNP 115103150 2084720461 2142272036 2133598344 2133776487
## 136    non-SNP 115103150 2084720461 2142272036 2133598344 2133776487
## 137    non-SNP 115103150 2084720461 2142272036 2133598344 2133776487
## 138    non-SNP 115103150 2084720461 2142272036 2147815461 2199052625
## 139    non-SNP 115103150 2084720461 2142272036 2147840461 2199052625
## 140        SNP 115103150 2084720461 2142272036 2148405610 2199823611
## 141    non-SNP 115103150 2084720461 2142272036 2148580461 2199815400
## 142    non-SNP 107282024 2199823611 2253464623 2219010790 2270858611
## 143    non-SNP 107282024 2199823611 2253464623 2219033611 2271338611
## 144    non-SNP 107282024 2199823611 2253464623 2219594468 2270858611
## 145        SNP 107282024 2199823611 2253464623 2220042694 2271391826
## 146    non-SNP 107282024 2199823611 2253464623 2270978611 2290113611
## 147    non-SNP 107282024 2199823611 2253464623 2270978611 2290113611
## 148        SNP 107282024 2199823611 2253464623 2271404389 2290624720
## 149    non-SNP 107282024 2199823611 2253464623 2271433611 2273528611
## 150    non-SNP 107282024 2199823611 2253464623 2273538611 2273973611
## 151    non-SNP 107282024 2199823611 2253464623 2274008611 2290583611
## 152    non-SNP 107282024 2199823611 2253464623 2290183611 2306575470
## 153    non-SNP 107282024 2199823611 2253464623 2290183611 2306620470
## 154    non-SNP 107282024 2199823611 2253464623 2290618611 2307078381
## 155        SNP 107282024 2199823611 2253464623 2290638953 2306660056
## 156        SNP 107282024 2199823611 2253464623 2306663451 2306754958
## 157        SNP 107282024 2199823611 2253464623 2306755432 2307105635
## 158    non-SNP 102430696 2307105635 2358320983 2327168262 2329174007
## 159        SNP 102430696 2307105635 2358320983 2327267007 2351607901
## 160    non-SNP 102430696 2307105635 2358320983 2327290635 2409536331
## 161    non-SNP 102430696 2307105635 2358320983 2327337914 2408956230
## 162    non-SNP 102430696 2307105635 2358320983 2329674756 2408981230
## 163        SNP 102430696 2307105635 2358320983 2351620206 2351883577
## 164        SNP 102430696 2307105635 2358320983 2351894252 2409502952
## 165    non-SNP  90222377 2409536331 2454647520 2409576331 2457546331
## 166    non-SNP  90222377 2409536331 2454647520 2409576331 2457546331
## 167    non-SNP  90222377 2409536331 2454647520 2409616331 2457701331
## 168        SNP  90222377 2409536331 2454647520 2409620218 2457711566
## 169    non-SNP  90222377 2409536331 2454647520 2457696331 2464531331
## 170    non-SNP  90222377 2409536331 2454647520 2457696331 2464531331
## 171        SNP  90222377 2409536331 2454647520 2457722291 2464673986
## 172    non-SNP  90222377 2409536331 2454647520 2457751331 2464576331
## 173        SNP  90222377 2409536331 2454647520 2464692836 2465415448
## 174    non-SNP  90222377 2409536331 2454647520 2464721331 2465321331
## 175    non-SNP  90222377 2409536331 2454647520 2464721331 2465321331
## 176    non-SNP  90222377 2409536331 2454647520 2464761331 2465421331
## 177        SNP  90222377 2409536331 2454647520 2465426061 2466234599
## 178    non-SNP  90222377 2409536331 2454647520 2465461331 2466266331
## 179    non-SNP  90222377 2409536331 2454647520 2465461331 2466266331
## 180    non-SNP  90222377 2409536331 2454647520 2465506331 2466251331
## 181        SNP  90222377 2409536331 2454647520 2466261141 2467520042
## 182    non-SNP  90222377 2409536331 2454647520 2466281331 2467531331
## 183    non-SNP  90222377 2409536331 2454647520 2466356331 2467461331
## 184    non-SNP  90222377 2409536331 2454647520 2466356331 2467461331
## 185    non-SNP  90222377 2409536331 2454647520 2467531331 2499685504
## 186    non-SNP  90222377 2409536331 2454647520 2467531331 2499695504
## 187        SNP  90222377 2409536331 2454647520 2467547781 2499694336
## 188    non-SNP  90222377 2409536331 2454647520 2467556331 2499758708
## 189    non-SNP  83168721 2499758708 2541343068 2499773708 2580881313
## 190    non-SNP  83168721 2499758708 2541343068 2499878708 2568238708
## 191    non-SNP  83168721 2499758708 2541343068 2499888708 2568238708
## 192        SNP  83168721 2499758708 2541343068 2500159667 2580022135
## 193    non-SNP  83168721 2499758708 2541343068 2507323805 2507349576
## 194    non-SNP  83168721 2499758708 2541343068 2507323805 2507349576
## 195    non-SNP  83168721 2499758708 2541343068 2507323805 2507349576
## 196    non-SNP  83168721 2499758708 2541343068 2507323805 2507349576
## 197    non-SNP  83168721 2499758708 2541343068 2512327915 2512429359
## 198    non-SNP  83168721 2499758708 2541343068 2512327915 2512429359
## 199    non-SNP  83168721 2499758708 2541343068 2512327915 2512429359
## 200    non-SNP  83168721 2499758708 2541343068 2512327915 2512429359
## 201    non-SNP  83168721 2499758708 2541343068 2568288708 2571828708
## 202    non-SNP  83168721 2499758708 2541343068 2568288708 2571828708
## 203    non-SNP  83168721 2499758708 2541343068 2571873708 2582927429
## 204    non-SNP  83168721 2499758708 2541343068 2571873708 2582927429
## 205        SNP  80206643 2582927429 2623030750 2582940271 2660935213
## 206    non-SNP  80206643 2582927429 2623030750 2582972429 2660936053
## 207    non-SNP  80206643 2582927429 2623030750 2583007429 2663134072
## 208    non-SNP  80206643 2582927429 2623030750 2583062429 2663134072
## 209    non-SNP  59099492 2663134072 2692683818 2663309072 2693024072
## 210    non-SNP  59099492 2663134072 2692683818 2663309072 2693024072
## 211    non-SNP  59099492 2663134072 2692683818 2663309072 2698014072
## 212        SNP  59099492 2663134072 2692683818 2663381304 2683304286
## 213        SNP  59099492 2663134072 2692683818 2683313686 2683596667
## 214        SNP  59099492 2663134072 2692683818 2683607625 2698050083
## 215    non-SNP  59099492 2663134072 2692683818 2693109072 2695504072
## 216    non-SNP  59099492 2663134072 2692683818 2693109072 2695504072
## 217    non-SNP  59099492 2663134072 2692683818 2693436973 2693449287
## 218    non-SNP  59099492 2663134072 2692683818 2693436973 2693449287
## 219    non-SNP  59099492 2663134072 2692683818 2693436973 2693449287
## 220    non-SNP  59099492 2663134072 2692683818 2693436973 2693449287
## 221    non-SNP  59099492 2663134072 2692683818 2695624072 2697524072
## 222    non-SNP  59099492 2663134072 2692683818 2695624072 2697524072
## 223    non-SNP  59099492 2663134072 2692683818 2697589072 2721722880
## 224    non-SNP  59099492 2663134072 2692683818 2697589072 2716694072
## 225    non-SNP  59099492 2663134072 2692683818 2698044072 2722233564
## 226        SNP  59099492 2663134072 2692683818 2698065976 2722227311
## 227    non-SNP  59099492 2663134072 2692683818 2716739072 2716899072
## 228    non-SNP  59099492 2663134072 2692683818 2716954072 2721722880
## 229        SNP  64292084 2722233564 2754379606 2722302658 2785146027
## 230    non-SNP  64292084 2722233564 2754379606 2722333564 2785161324
## 231    non-SNP  64292084 2722233564 2754379606 2722411732 2786525648
## 232    non-SNP  64292084 2722233564 2754379606 2722411732 2786525648
## 233    non-SNP  48099948 2786525648 2810575622 2791580648 2833205640
## 234        SNP  48099948 2786525648 2810575622 2796173963 2834623258
## 235    non-SNP  48099948 2786525648 2810575622 2797095092 2833205640
## 236    non-SNP  48099948 2786525648 2810575622 2797369596 2834625596
## 237    non-SNP  51213826 2834625596 2860232509 2850047755 2885394830
## 238        SNP  51213826 2834625596 2860232509 2850680309 2858966984
## 239    non-SNP  51213826 2834625596 2860232509 2850790596 2885837879
## 240    non-SNP  51213826 2834625596 2860232509 2851192601 2885394830
## 241        SNP  51213826 2834625596 2860232509 2858972024 2859015914
## 242        SNP  51213826 2834625596 2860232509 2859019684 2885839422
## [[1]]

## 
## [[2]]
##          seg.mean loc.start   loc.end chrom         type     CNVStatus  Gene
## 1   -0.3777818159    747994  28115000     1 MethylMaster      Deletion     0
## 2   -0.7534818159  28185000  28505000     1 MethylMaster      Deletion     0
## 3   -0.4224818159  28530000  38525000     1 MethylMaster      Deletion     0
## 4    0.1562181841  38690000 186405000     1 MethylMaster        Normal     0
## 5    0.3858181841 186560000 199570000     1 MethylMaster Amplification     0
## 6    0.1513181841 199885000 208295000     1 MethylMaster        Normal     0
## 7   -0.3127818159 208480000 248923211     1 MethylMaster      Deletion     0
## 8   -0.5230000000    754192  39046130     1          SNP      Deletion     0
## 9    0.3290000000  39053684  71837405     1          SNP Amplification     0
## 10   0.5860000000  71858457  72654730     1          SNP Amplification     0
## 11   0.3720000000  72662685  76640953     1          SNP Amplification     0
## 12  -0.0230000000  76658494  77726109     1          SNP        Normal     0
## 13   0.3400000000  77737217  93047956     1          SNP Amplification     0
## 14   0.0030000000  93073228  98750052     1          SNP        Normal     0
## 15   0.3250000000  98766448 100543962     1          SNP Amplification     0
## 16  -0.0280000000 100549400 110221639     1          SNP        Normal     0
## 17   0.2600000000 110222219 111181086     1          SNP Amplification     0
## 18  -0.0210000000 111193595 152411090     1          SNP        Normal     0
## 19   0.3470000000 152411813 208551533     1          SNP Amplification     0
## 20  -0.5640000000 208569475 249212878     1          SNP      Deletion     0
## 21  -0.3056818159    110000  46830000     2 MethylMaster      Deletion     0
## 22  -1.3103818159  46880000  49160000     2 MethylMaster      Deletion     0
## 23  -0.3053818159  49835000 200815000     2 MethylMaster      Deletion     0
## 24  -0.5376818159 200840000 201305000     2 MethylMaster      Deletion     0
## 25  -0.3142818159 201405000 242111765     2 MethylMaster      Deletion     0
## 26  -0.5260000000     21494  47051551     2          SNP      Deletion     0
## 27  -1.6880000000  47067057  49997218     2          SNP      Deletion     0
## 28  -0.5610000000  50007748 243052331     2          SNP      Deletion     0
## 29   0.0185181841    115000 198097780     3 MethylMaster        Normal     0
## 30  -0.0690000000     63411 197852564     3          SNP        Normal     0
## 31   0.0581181841    110000 190066561     4 MethylMaster        Normal     0
## 32  -0.5940000000     69404    334213     4          SNP      Deletion     0
## 33  -0.0470000000    360026 180023290     4          SNP        Normal     0
## 34  -0.4110000000 180040368 180365623     4          SNP      Deletion     0
## 35  -0.0540000000 180392930 190915650     4          SNP        Normal     0
## 36   0.0446181841     50000 181369130     5 MethylMaster        Normal     0
## 37  -0.0080000000     38139    392863     5          SNP        Normal     0
## 38   0.2300000000    412226    788914     5          SNP Amplification     0
## 39  -0.0070000000    804103 180698312     5          SNP        Normal     0
## 40  -0.0131818159    140000 170662990     6 MethylMaster        Normal     0
## 41  -0.0320000000    204909 170913051     6          SNP        Normal     0
## 42  -0.3608818159     50000 159247987     7 MethylMaster      Deletion     0
## 43  -0.5470000000     41421 159118443     7          SNP      Deletion     0
## 44   0.0127181841    195000 145039318     8 MethylMaster        Normal     0
## 45  -0.0200000000    172417  39194984     8          SNP        Normal     0
## 46  -1.6230000000  39217074  39460780     8          SNP      Deletion     0
## 47  -0.0250000000  39480366 146292734     8          SNP        Normal     0
## 48  -0.0264818159    215000 138187359     9 MethylMaster        Normal     0
## 49  -0.0240000000    204738   5021738     9          SNP        Normal     0
## 50  -0.2510000000   5023689   5069837     9          SNP      Deletion     0
## 51  -0.0480000000   5071049 129580187     9          SNP        Normal     0
## 52  -0.2400000000 129582563 129844541     9          SNP      Deletion     0
## 53   0.0000000000 129854773 141054761     9          SNP        Normal     0
## 54   0.0141181841    125000  74415000    10 MethylMaster        Normal     0
## 55  -0.3479818159  74595000 133625233    10 MethylMaster      Deletion     0
## 56  -0.0340000000    126070  76263261    10          SNP        Normal     0
## 57  -0.5810000000  76287336 135434303    10          SNP      Deletion     0
## 58  -0.0006818159    145000  62735000    11 MethylMaster        Normal     0
## 59  -0.3424818159  62760000  62840000    11 MethylMaster      Deletion     0
## 60  -0.0074818159  62865000 134993311    11 MethylMaster        Normal     0
## 61  -0.0150000000    192764 134938847    11          SNP        Normal     0
## 62   0.0027181841     70000 133222655    12 MethylMaster        Normal     0
## 63  -0.0310000000    189400 133818115    12          SNP        Normal     0
## 64   0.0403181841  18679053  47270000    13 MethylMaster        Normal     0
## 65  -0.3266818159  47630000  61950000    13 MethylMaster      Deletion     0
## 66   0.0940181841  63095000 114332164    13 MethylMaster        Normal     0
## 67  -0.0190000000  19084823  48054661    13          SNP        Normal     0
## 68  -0.5470000000  48058244  63661960    13          SNP      Deletion     0
## 69   0.0190000000  63685149 115103150    13          SNP        Normal     0
## 70   0.0220181841  19770857  71035000    14 MethylMaster        Normal     0
## 71  -0.3619818159  71155000  90290000    14 MethylMaster      Deletion     0
## 72  -0.0233818159  90360000 106751859    14 MethylMaster        Normal     0
## 73  -0.0220000000  20219083  71568215    14          SNP        Normal     0
## 74  -0.6010000000  71580778  90801109    14          SNP      Deletion     0
## 75   0.0170000000  90815342 106836445    14          SNP        Normal     0
## 76  -0.2410000000 106839840 106931347    14          SNP      Deletion     0
## 77  -0.0370000000 106931821 107282024    14          SNP        Normal     0
## 78  -0.0141818159  20232279 101850595    15 MethylMaster        Normal     0
## 79  -0.0180000000  20161372  44502266    15          SNP        Normal     0
## 80   0.2050000000  44514571  44777942    15          SNP Amplification     0
## 81  -0.0040000000  44788617 102397317    15          SNP        Normal     0
## 82  -0.0895818159     40000  48010000    16 MethylMaster        Normal     0
## 83  -0.3532818159  48160000  54995000    16 MethylMaster      Deletion     0
## 84  -0.0350818159  55185000  55785000    16 MethylMaster        Normal     0
## 85  -0.3510818159  55925000  56730000    16 MethylMaster      Deletion     0
## 86  -0.0746818159  56820000  57925000    16 MethylMaster        Normal     0
## 87  -0.3635818159  57995000  90149173    16 MethylMaster      Deletion     0
## 88   0.0300000000     83887  48175235    16          SNP        Normal     0
## 89  -0.5670000000  48185960  55137655    16          SNP      Deletion     0
## 90   0.0520000000  55156505  55879117    16          SNP        Normal     0
## 91  -0.5860000000  55889730  56698268    16          SNP      Deletion     0
## 92   0.0290000000  56724810  57983711    16          SNP        Normal     0
## 93  -0.5640000000  58011450  90158005    16          SNP      Deletion     0
## 94  -0.0707818159    130000  68480000    17 MethylMaster        Normal     0
## 95   0.1569181841  68530000  72070000    17 MethylMaster        Normal     0
## 96  -0.0682818159  72115000  83168721    17 MethylMaster        Normal     0
## 97   0.0000000000    400959  80263427    17          SNP        Normal     0
## 98   0.0574181841    135000  80206643    18 MethylMaster        Normal     0
## 99   0.0010000000     12842  78007784    18          SNP        Normal     0
## 100 -0.1467818159    175000  29890000    19 MethylMaster        Normal     0
## 101  0.0527181841  29975000  32370000    19 MethylMaster        Normal     0
## 102 -0.1348818159  32490000  34390000    19 MethylMaster        Normal     0
## 103 -0.4709818159  34455000  58588808    19 MethylMaster      Deletion     0
## 104  0.0100000000    247232  20170214    19          SNP        Normal     0
## 105 -0.3030000000  20179614  20462595    19          SNP      Deletion     0
## 106 -0.0540000000  20473553  34916011    19          SNP        Normal     0
## 107 -0.5750000000  34931904  59093239    19          SNP      Deletion     0
## 108 -0.0246818159    178168  64292084    20 MethylMaster        Normal     0
## 109 -0.0130000000     69094  62912463    20          SNP        Normal     0
## 110  0.0343181841  10569444  46679992    21 MethylMaster        Normal     0
## 111  0.0440000000   9648315  48097610    21          SNP        Normal     0
## 112 -0.0662818159  16567005  50769234    22 MethylMaster        Normal     0
## 113  0.0300000000  16054713  24341388    22          SNP        Normal     0
## 114  0.6420000000  24346428  24390318    22          SNP Amplification     0
## 115  0.0210000000  24394088  51213826    22          SNP        Normal     0
## 116 -0.3008000000    677994  16510000     1       SeSAMe      Deletion     0
## 117  0.0215000000  16570000  16779582     1       SeSAMe        Normal     0
## 118 -0.3448000000  16869582  28185000     1       SeSAMe      Deletion     0
## 119 -0.6069000000  28275000  28695000     1       SeSAMe      Deletion     0
## 120 -0.3593000000  28795000  38525000     1       SeSAMe      Deletion     0
## 121  0.2126000000  38690000 186405000     1       SeSAMe        Normal     0
## 122  0.4444000000 186560000 199570000     1       SeSAMe Amplification     0
## 123  0.2130000000 199885000 208295000     1       SeSAMe        Normal     0
## 124 -0.2521000000 208480000 248923211     1       SeSAMe        Normal     0
## 138 -0.2467000000    110000  46830000     2       SeSAMe        Normal     0
## 139 -1.2535000000  46880000  49160000     2       SeSAMe      Deletion     0
## 140 -0.2428000000  49835000 200815000     2       SeSAMe        Normal     0
## 141 -0.4734000000 200840000 201305000     2       SeSAMe      Deletion     0
## 142 -0.2557000000 201405000 242111765     2       SeSAMe        Normal     0
## 146  0.0762000000    115000 198172780     3       SeSAMe        Normal     0
## 148  0.1150000000     65000 190066561     4       SeSAMe        Normal     0
## 153  0.1023000000     50000 181369130     5       SeSAMe        Normal     0
## 157  0.0438000000    140000 170662990     6       SeSAMe        Normal     0
## 159 -0.3015000000     50000 159247987     7       SeSAMe      Deletion     0
## 161  0.0701000000    160000 145039318     8       SeSAMe        Normal     0
## 165  0.0336000000    110000 138227359     9       SeSAMe        Normal     0
## 171  0.0729000000     70000  74415000    10       SeSAMe        Normal     0
## 172 -0.2900000000  74595000 133625233    10       SeSAMe        Normal     0
## 175  0.0508000000    130000 135013311    11       SeSAMe        Normal     0
## 177  0.0600000000     55000 133222655    12       SeSAMe        Normal     0
## 179  0.1000000000  18639053  47270000    13       SeSAMe        Normal     0
## 180 -0.2705000000  47630000  62140000    13       SeSAMe        Normal     0
## 181  0.1508000000  63120000 114332164    13       SeSAMe        Normal     0
## 185  0.0794000000  19187179  71035000    14       SeSAMe        Normal     0
## 186 -0.3041000000  71155000  90290000    14       SeSAMe      Deletion     0
## 187  0.0322000000  90360000 106796859    14       SeSAMe        Normal     0
## 193 -0.3009000000  20062627  22068372    15       SeSAMe      Deletion     0
## 194  0.0452000000  22569121 101875595    15       SeSAMe        Normal     0
## 198 -0.0305000000     40000  48010000    16       SeSAMe        Normal     0
## 199 -0.2948000000  48160000  54995000    16       SeSAMe        Normal     0
## 200  0.0270000000  55185000  55785000    16       SeSAMe        Normal     0
## 201 -0.2897000000  55925000  56730000    16       SeSAMe        Normal     0
## 202 -0.0154000000  56820000  57925000    16       SeSAMe        Normal     0
## 203 -0.2987000000  57995000  90159173    16       SeSAMe        Normal     0
## 210 -0.0107000000    120000  68480000    17       SeSAMe        Normal     0
## 211  0.2163000000  68530000  72070000    17       SeSAMe        Normal     0
## 212 -0.0098000000  72115000  83168721    17       SeSAMe        Normal     0
## 214  0.1163000000     80000  80206643    18       SeSAMe        Normal     0
## 216 -0.0894000000    175000  29890000    19       SeSAMe        Normal     0
## 217  0.1090000000  29975000  32370000    19       SeSAMe        Normal     0
## 218 -0.0719000000  32490000  34390000    19       SeSAMe        Normal     0
## 219 -0.4152000000  34455000  53560000    19       SeSAMe      Deletion     0
## 220 -0.7416000000  53605000  53765000    19       SeSAMe      Deletion     0
## 221 -0.3768000000  53820000  58588808    19       SeSAMe      Deletion     0
## 226  0.0340000000    178168  64292084    20       SeSAMe        Normal     0
## 228  0.0914000000   5055000  46679992    21       SeSAMe        Normal     0
## 230 -0.0092000000  15422159  50769234    22       SeSAMe        Normal     0
## 234 -0.3180000000     93709  39040000     1      Conumee      Deletion     0
## 235  0.1910000000  39115000  93105000     1      Conumee        Normal     0
## 236  0.0430000000  93270000  98515000     1      Conumee        Normal     0
## 237  0.2900000000  98685000 100545000     1      Conumee Amplification     0
## 238  0.0330000000 100595000 110285000     1      Conumee        Normal     0
## 239  0.1820000000 110300000 111505000     1      Conumee        Normal     0
## 240  0.0110000000 111595000 152240000     1      Conumee        Normal     0
## 241  0.1900000000 152315000 185705000     1      Conumee        Normal     0
## 242  0.3630000000 185820000 199735000     1      Conumee Amplification     0
## 243  0.1580000000 199910000 208510000     1      Conumee        Normal     0
## 244 -0.2790000000 208690000 249220311     1      Conumee      Deletion     0
## 258 -0.2890000000     30000  47050000     2      Conumee      Deletion     0
## 259 -1.2360000000  47095000  49795000     2      Conumee      Deletion     0
## 260 -0.2900000000  50395000 243046238     2      Conumee      Deletion     0
## 264  0.0200000000    150000 197881215     3      Conumee        Normal     0
## 266  0.0500000000     35000 190992138     4      Conumee        Normal     0
## 271  0.0460000000     35000 180797630     5      Conumee        Normal     0
## 275  0.0250000000    130000 170977534     6      Conumee        Normal     0
## 277 -0.3160000000     40000 159044332     7      Conumee      Deletion     0
## 279  0.0260000000     95000 146267011     8      Conumee        Normal     0
## 283 -0.0160000000    110000 141081716     9      Conumee        Normal     0
## 289  0.0060000000     80000  76205000    10      Conumee        Normal     0
## 290 -0.3020000000  76310000 135482374    10      Conumee      Deletion     0
## 293  0.0090000000    130000 134893258    11      Conumee        Normal     0
## 295  0.0020000000    182870 133795948    12      Conumee        Normal     0
## 297  0.0290000000  19100000  47985000    13      Conumee        Normal     0
## 298 -0.2610000000  48350000  63100000    13      Conumee      Deletion     0
## 299  0.0660000000  63860000 115094939    13      Conumee        Normal     0
## 303  0.0330000000  19210000  71515000    14      Conumee        Normal     0
## 304 -0.3240000000  71610000  73705000    14      Conumee      Deletion     0
## 305 -0.5770000000  73715000  74150000    14      Conumee      Deletion     0
## 306 -0.3150000000  74185000  90760000    14      Conumee      Deletion     0
## 307 -0.0080000000  90795000 107254770    14      Conumee        Normal     0
## 313  0.0030000000  20185000 102430696    15      Conumee        Normal     0
## 317 -0.0810000000     80000  48165000    16      Conumee        Normal     0
## 318 -0.3090000000  48215000  55040000    16      Conumee      Deletion     0
## 319  0.0300000000  55225000  55885000    16      Conumee        Normal     0
## 320 -0.3250000000  55970000  56715000    16      Conumee      Deletion     0
## 321 -0.0410000000  56745000  57995000    16      Conumee        Normal     0
## 322 -0.3390000000  58020000  90222377    16      Conumee      Deletion     0
## 329 -0.0470000000     15000  81122605    17      Conumee        Normal     0
## 331  0.0330000000     45000  78008624    18      Conumee        Normal     0
## 333 -0.1290000000    175000  34880000    19      Conumee        Normal     0
## 334 -0.4130000000  34910000  59099492    19      Conumee      Deletion     0
## 339 -0.0220000000    100000  62927760    20      Conumee        Normal     0
## 341  0.0070000000  10843948  48099948    21      Conumee        Normal     0
## 343 -0.0470000000  16165000  51212283    22      Conumee        Normal     0
## 347  0.0127181841 128747765 128753680     8 Gene_MMasteR        Normal  4609
## 348 -0.0250000000 128747765 128753680     8     Gene_SNP        Normal  4609
## 349 -0.0264818159  21967751  21994490     9 Gene_MMasteR        Normal  1029
## 350 -0.0480000000  21967751  21994490     9     Gene_SNP        Normal  1029
## 351 -0.3479818159  89623195  89728532    10 Gene_MMasteR      Deletion  5728
## 352 -0.5810000000  89623195  89728532    10     Gene_SNP      Deletion  5728
## 353 -0.3266818159  48877883  49056026    13 Gene_MMasteR      Deletion  5925
## 354 -0.5470000000  48877883  49056026    13     Gene_SNP      Deletion  5925
## 355 -0.0707818159   7565097   7590868    17 Gene_MMasteR        Normal  7157
## 356 -0.0707818159  12569207  12670651    17 Gene_MMasteR        Normal 93649
## 357  0.0000000000   7565097   7590868    17     Gene_SNP        Normal  7157
## 358  0.0000000000  12569207  12670651    17     Gene_SNP        Normal 93649
## 359  0.0527181841  30302901  30315215    19 Gene_MMasteR        Normal   898
## 360 -0.0540000000  30302901  30315215    19     Gene_SNP        Normal   898
## 361  0.0701000000 128747765 128753680     8  Gene_SeSAMe        Normal  4609
## 362  0.0336000000  21967751  21994490     9  Gene_SeSAMe        Normal  1029
## 363 -0.2900000000  89623195  89728532    10  Gene_SeSAMe        Normal  5728
## 364 -0.2705000000  48877883  49056026    13  Gene_SeSAMe        Normal  5925
## 365 -0.0107000000   7565097   7590868    17  Gene_SeSAMe        Normal  7157
## 366 -0.0107000000  12569207  12670651    17  Gene_SeSAMe        Normal 93649
## 367  0.1090000000  30302901  30315215    19  Gene_SeSAMe        Normal   898
## 368  0.0260000000 128747765 128753680     8 Gene_Conumee        Normal  4609
## 369 -0.0160000000  21967751  21994490     9 Gene_Conumee        Normal  1029
## 370 -0.3020000000  89623195  89728532    10 Gene_Conumee      Deletion  5728
## 371 -0.2610000000  48877883  49056026    13 Gene_Conumee      Deletion  5925
## 372 -0.0470000000   7565097   7590868    17 Gene_Conumee        Normal  7157
## 373 -0.0470000000  12569207  12670651    17 Gene_Conumee        Normal 93649
## 374 -0.1290000000  30302901  30315215    19 Gene_Conumee        Normal   898

It looks terribly compressed, but this is honestly just due to the limits of this RMD file. Saving it with the proper parameters make it look more like this:

A lot more elegant!
A lot more elegant!

Conclusion

That’s about it! This whole pipeline gives an elegant flow, from preprocessing the data into a common readable format, to the different forms of analysis, all the way down to the visualizations, step by step.