Description Usage Arguments Value Examples
View source: R/NamesDeltaBetaCut.R
The purpose of this function is to find the row names or indices of the CpG probe that have a certain absolute delta beta-value difference between two groups of choice. The function is restricted to comparison of two groups.
1 2 3 4 5 6 7 8 9 10 | NamesDeltaBetaCut(
pd,
feature,
beta,
group1_Name,
group2_Name,
deltaBetaThreshold = 0.2,
returnIndeces = F,
sampleNames = "Sample_Name"
)
|
pd |
A minfi- or ChAMP-type sample sheet. |
feature |
The name of the group variable as it appears in the sample sheet. |
beta |
A beta-value matrix, where rows are CpG probes and columns are samples. |
group1_Name |
The string representation of the factor corresponding to group 1 in the group variable "feature". |
group2_Name |
Same as above, but for the other group. |
deltaBetaThreshold |
The desired delta beta-value threshold. The delta beta-value is the mean difference in beta-values between two groups. The value is converted to an absolute value. The default is 0.2. |
returnIndeces |
By setting "returnIndices" to "TRUE" the function will return the indices of the CpG probes in the original beta-value matrix instead of the row names. Is set to "FALSE" by default. |
sampleNames |
If the column containing the sample names in the pd is not named "Sample_Name" (ChAMP default naming convention), the column name has to be added separately. By default the function assumes the name to be "Sample_Name". |
A vector containing the row names (by default the CpG-probe ID) or indices of CpG-probes that have a user-defined delta beta difference between two groups of interest.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | # create some random matrix
A <- data.frame(runif(1000,0.2,1),runif(1000,0.3,1),runif(1000,0.5,0.99),
runif(1000,0.1,0.7),runif(1000,0.2,0.6),runif(1000,0,0.6))
rownames(A) <- paste("cg",sample(10000000:99999999,1000,replace = FALSE), sep ="")
colnames(A) <- rep(paste("Sample_",1:6,sep=""))
pd <- cbind.data.frame(colnames(A),c(rep("Group_1",3),rep("Group_2",3)))
colnames(pd) <- c("Sample_Names","Groups")
inclusion <- NamesDeltaBetaCut(pd = pd,
feature = pd$Groups,
beta = A,
group1_Name = "Group_1",
group2_Name = "Group_2",
deltaBetaThreshold = 0.2,
returnIndeces = FALSE,
sampleNames = "Sample_Names")
# Plot results
A_filtered <- A[rownames(A) %in% inclusion,]
Group1 <- paste("^",pd[which(pd$Groups == "Group_1"), "Sample_Names"],"$",
collapse = "|", sep = "")
Group2 <- paste("^",pd[which(pd$Groups == "Group_2"), "Sample_Names"],"$",
collapse = "|", sep = "")
meanG1 <- rowMeans(A[,grep(Group1, colnames(A))])
meanG2 <- rowMeans(A[,grep(Group2, colnames(A))])
hist(meanG1-meanG2, xlab = "delta beta-values",
main = "All (grey) vs. filtered delta beta-values (red)")
meanG1_filtered <- rowMeans(A_filtered[,grep(Group1, colnames(A_filtered))])
meanG2_filtered <- rowMeans(A_filtered[,grep(Group2, colnames(A_filtered))])
hist(meanG1_filtered-meanG2_filtered, col = rgb(0.8,0.1,0.1,0.3),add = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.