Difference between revisions of "VennDiagram.R"
From Organic Design wiki
m |
(Code update) |
||
Line 1: | Line 1: | ||
<pre> | <pre> | ||
# This illustrates a problem with missing values | # This illustrates a problem with missing values | ||
+ | library(limma) | ||
+ | |||
+ | graphics.off() | ||
+ | |||
p <- 100 | p <- 100 | ||
n <- 3 | n <- 3 | ||
Line 11: | Line 15: | ||
} | } | ||
− | + | # Two copies one containing missing information | |
+ | x.NA <- x | ||
+ | |||
vennDiagram(x) | vennDiagram(x) | ||
+ | title("Simulated venn diagram without missing values") | ||
x[4,] | x[4,] | ||
− | x[4,3] <- NA | + | x.NA[4,3] <- NA |
+ | |||
+ | |||
+ | X11() | ||
+ | vennDiagram(x.NA) | ||
+ | title("Simulated venn diagram with missing values") | ||
+ | # Printing output from A:B intersection | ||
vennCounts(x)[7,] | vennCounts(x)[7,] | ||
− | + | vennCounts(x.NA)[7,] | |
− | + | # Note missing value in row 7 has reduced the venn diagram count | |
+ | # This removes all information about that observation even though we know that | ||
+ | # there was valid information about A and B in row 7, so that information had | ||
+ | # to of been either a A:B interaction or an A:B:C interaction | ||
</pre> | </pre> |
Latest revision as of 21:44, 6 August 2007
# This illustrates a problem with missing values library(limma) graphics.off() p <- 100 n <- 3 x <- matrix(0, nr=p,nc=n) colnames(x) <- LETTERS[1:3] set.seed(1) for(i in 1:n) { x[,i] <- rbinom(p, 1, 1/10) } # Two copies one containing missing information x.NA <- x vennDiagram(x) title("Simulated venn diagram without missing values") x[4,] x.NA[4,3] <- NA X11() vennDiagram(x.NA) title("Simulated venn diagram with missing values") # Printing output from A:B intersection vennCounts(x)[7,] vennCounts(x.NA)[7,] # Note missing value in row 7 has reduced the venn diagram count # This removes all information about that observation even though we know that # there was valid information about A and B in row 7, so that information had # to of been either a A:B interaction or an A:B:C interaction