How to create a Venn Diagram
from data frame
and get the list of common Genes
expressed in each combination?
I have a data frame of DEG, How can I create a Venn Diagram
from data frame
and get the list of common Genes
?
Note: data frame has NA for some genotypes for some Genes, If all the genotypes are NA for a particular gene, that raw should be ignored.
Gene Genotype1 Genotype2 Genotype3 Genotype4
AT1G17400 NA NA NA NA
AT1G09420 NA 0.000800188 0.000116452 0.004017191
AT1G50930 NA NA NA NA
AT1G65960 NA NA NA NA
AT1G09400 NA NA NA NA
AT1G09415 NA NA NA NA
AT1G74730 NA NA NA NA
AT1G75100 0.001639398 0.001578892 6.92E-05 NA
AT1G75100 0.001639398 0.001578892 6.92E-05 NA
AT1G75240 NA 5.60E-05 0.000235329 0.000162115
AT1G14920 NA NA NA NA
AT1G14920 NA NA NA NA
AT1G65510 NA NA NA NA
AT1G75250 NA NA NA NA
AT1G54410 NA 0.000113869 1.25E-05 NA
We could improve data preparation for
venn
as:This is the answer I want :) Thank you dsull. BTW, How can I find what gene IDs went to each common category? How Can I export them out?
Well, if you want to know what genes belong to a certain category, say Genotype 1, you can simply print them out via:
print(Genotype1)
If you want to quickly see something like: genes that belong to Genotype1 and Genotype3 but don't belong to Genotype2 and Genotype4, again, you can subset your dataframe as follows:
data[!is.na(data$Genotype1) & !is.na(data$Genotype3) & is.na(data$Genotype2) & is.na(data$Genotype4),"Gene"]
Basically, the exclamation point is the negation symbol so
!is.na
means the genes that are not-NA whereasis.na
means the genes that are NA. The ampersand (&) means AND. Look into subsetting dataframes in R for more details.Thanks a heap, dsull :) Appreciate.