knitr::opts_chunk$set(echo = TRUE)
This is a short introduction into CN Analysis with the cnAnalysis450k package. The aim is to identify segmental alterations for a given set of samples. For a complete overview for several ways of analyzing and the neccessary parameters refer to the "completeWorkflow" vignette.
## Load data from the minfiData package or minfiDataEPIC #dataset <- minfiDataEPIC::RGsetEPIC dataset <- minfiData::RGsetEx #Normalize data normData <- minfi:::getCN(minfi::preprocessIllumina( dataset)) #Controls ctrlAll <- normData[,1:3] ctrlAll[is.infinite(ctrlAll)] <- NA ctrlAll <- scale(ctrlAll) ctrl <- apply(ctrlAll, 1, "median") #Samples samples <- normData[,4:6] samples[is.infinite(samples)] <- NA samples <- scale(samples)
##Process data ## ~15 sek candidatesDATA <- cnAnalysis450k::findSegments(samples[, , drop = FALSE], ctrl, ctrlAll) candidatesMATRIX <- cnAnalysis450k::createSegmentMatrix(candidatesDATA, p.select = 0.01) candidatesCUT <- cnAnalysis450k::findCutoffs(candidatesMATRIX, proximity = c(2, 1)) candidatesFINAL <- cnAnalysis450k::segmentData(candidatesMATRIX, candidatesCUT, effectsize = c(0.15, 0.1)) ##Display anno_row <- data.frame(do.call(rbind, strsplit(rownames(candidatesFINAL), ":"))) rownames(anno_row) <- rownames(candidatesFINAL) colnames(anno_row) <- c("Chromosome", "Startpos") anno_row$Chromosome <- factor(anno_row$Chromosome, levels = paste("chr", 1:22, sep = "")) pheatmap::pheatmap(candidatesFINAL, annotation_row = anno_row[, "Chromosome", drop = FALSE], cluster_rows = FALSE)
##Process data candidatesDATA <- cnAnalysis450k::createBinsFast(samples, ctrl, ctrlAll, binsize = 500000) candidatesMATRIX <- cnAnalysis450k::createBinMatrix(candidatesDATA, pval=1) candidatesCUT <- cnAnalysis450k::findCutoffs(candidatesMATRIX, ignoreNAs=T) candidatesFINAL <- cnAnalysis450k::segmentData(candidatesMATRIX, candidatesCUT, effectsize = c(0.05, 0.05)) ##Display anno_row <- data.frame(do.call(rbind, strsplit(rownames(candidatesFINAL), ":"))) colnames(anno_row) <- c("chr", "startCG", "pos") rownames(anno_row) <- rownames(candidatesFINAL) pheatmap::pheatmap(candidatesFINAL[which(anno_row$chr=="chr19"),], annotation_row=anno_row[,"chr",drop=F], cluster_rows = FALSE, cluster_cols=FALSE, show_rownames=F)
## All transcripts tx <- GenomicFeatures::transcripts( TxDb.Hsapiens.UCSC.hg19.knownGene::TxDb.Hsapiens.UCSC.hg19.knownGene)$tx_name candidatesDATA <- cnAnalysis450k::getTxValuesFast(samples, ctrl, ctrlAll, tx) candidatesMATRIX <- candidatesDATA$data[which(candidatesDATA$p.val <= 0.05), ] candidatesCUT <- cnAnalysis450k::findCutoffs(candidatesMATRIX, ignoreNAs=T) candidatesFINAL <- cnAnalysis450k::segmentData(candidatesMATRIX, candidatesCUT, effectsize = c(0.05, 0.05))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.