[R] how to draw stacked ellipses to illustrate the shared and specific of multiple objects using R

Jim Lemon jim at bitwrit.com.au
Tue Oct 20 10:16:08 CEST 2009


On 10/20/2009 06:10 PM, Mao Jianfeng wrote:
> Dear R-help listers,
>
> I am now asking for helps on how to draw stacked ellipses to
> illustrate the shared and specific of multiple objects using R.
>
> My problem comes from my population genetics study. Now, I genotyped
> three species, and I get known about the amount of shared and specific
> haplotypes in each of the species and their combinations. I want to
> illustrate this result in three stack ellipses, with the shared and
> unique area of the stack ellipses were annotated with the relative
> amount.
>
>   my data is as followed:
>
> ------------------------------------------------------------
> hap.type	hap.dis.num	hap.dis.per	types
> hap.Pd	8	27.5862069	Pd specific
> hap.Pt	6	20.68965517	Pt specific
> hap.Py	9	31.03448276	Py specific
> hap.PdPt	3	10.34482759	PdPt shared
> hap.PdPy	3	10.34482759	PdPy shared
> hap.PtPy	0	0	PtPy shared
> hap.3P	0	0	3 species shared
> -------------------------------------------------------------
>
> Several individuals of 3 species (Pd, Pt, Py) were genotyped, the
> summary of haplotype distribution in species level were contained in
> the forward dataset.
>
> Could you please give any direction on this graphical problem? Thank
> you in advance.
>    
Hi Mao,
I can't help you with ellipses, but intersectDiagram in the plotrix 
package may do what you want in a different way. Try this:

library(plotrix)
hapIntList<-
  getIntersectList(3,xnames=c("hap.Pd","hap.Pt","hap.Py"))
# enter the data as follows
#Number of elements in hap.Pd - 1: 27.586
#Number of elements in hap.Pt - 1: 20.689
#Number of elements in hap.Py - 1: 31.034
#Number of elements in hap.Pdhap.Pt - 1: 10.345
#Number of elements in hap.Pdhap.Py - 1: 10.345
#Number of elements in hap.Pthap.Py - 1: 0
#Number of elements in hap.Pdhap.Pthap.Py - 1: 0
#Total number of elements - 1: 99.999
# this is a small bug that I have fixed and will
# not be necessary from v2.7-2 onward
class(hapIntList)<-"intersectList"
intersectDiagram(hapIntList)

I'm quite interested in whether this is of any use to you, as I had not 
even thought of this particular use for intersectDiagram.

Jim




More information about the R-help mailing list