RE: Structure Plot

12 views
Skip to first unread message

Roy Francis Mathew

unread,
Jan 14, 2011, 9:57:41 AM1/14/11
to ggp...@googlegroups.com

Hi,

I was wondering if its possible to create this sort of graph (result from structure software for population genetics) from the data below.

 

Image>

http://tinypic.com/r/1z3nhhd/7

 

I decided to describe the image as it is too small to see details. The values in data column ‘Sample’ are the x axis points on the graph.

The y axis extends from 0 to 1, which is adds up columns cluster01, cluster02 and cluster03. The colours correspond to the 3 clusters.

I am not sure if all that made sense.

 

data>

Sample        Cluster  01                    Cluster  02                    Cluster  03  

000001:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000002:       0.000750000000000        0.999250000000000        0.000000000000000                          1

000003:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000004:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000005:       0.000450000000000        0.999550000000000        0.000000000000000                          1

000006:       0.000500000000000        0.999500000000000        0.000000000000000                          1

000007:       0.102725000000000        0.897250000000000        0.000025000000000                          1

000008:       0.000425000000000        0.999575000000000        0.000000000000000                          1

000009:       0.070425000000000        0.929575000000000        0.000000000000000                          1

000010:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000011:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000012:       0.011425000000000        0.988575000000000        0.000000000000000                          1

000013:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000014:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000015:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000016:       0.088225000000000        0.911775000000000        0.000000000000000                          1

000017:       0.082550000000000        0.917400000000000        0.000050000000000                          1

000018:       0.000175000000000        0.999825000000000        0.000000000000000                          1

000019:       0.000025000000000        0.999975000000000        0.000000000000000                          1

000020:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000021:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000022:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000023:       0.000400000000000        0.999600000000000        0.000000000000000                          1

000024:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000025:       0.000050000000000        0.999950000000000        0.000000000000000                          1

000026:       0.000075000000000        0.999925000000000        0.000000000000000                          1

000027:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000028:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000029:       0.020975000000000        0.979025000000000        0.000000000000000                          1

000030:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000031:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000032:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000033:       0.262200000000000        0.737725000000000        0.000075000000000                          1

000034:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000035:       0.203375000000000        0.796625000000000        0.000000000000000                          1

000036:       0.000700000000000        0.999300000000000        0.000000000000000                          1

000037:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000038:       0.174400000000000        0.825600000000000        0.000000000000000                          1

000039:       0.000600000000000        0.999400000000000        0.000000000000000                          1

000040:       0.000000000000000        1.000000000000000        0.000000000000000                          1

000041:       0.000025000000000        0.999975000000000        0.000000000000000                          1

000042:       0.000125000000000        0.999875000000000        0.000000000000000                          1

000043:       0.000450000000000        0.999550000000000        0.000000000000000                          1

000044:       0.000200000000000        0.999700000000000        0.000100000000000                          1

000045:       0.999975000000000        0.000025000000000        0.000000000000000                          1

000046:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000047:       0.999775000000000        0.000000000000000        0.000225000000000                          1

000048:       0.997900000000000        0.000600000000000        0.001500000000000                          1

000049:       0.999450000000000        0.000000000000000        0.000550000000000                          1

000050:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000051:       0.999950000000000        0.000000000000000        0.000050000000000                          1

000052:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000053:       0.999450000000000        0.000225000000000        0.000325000000000                          1

000054:       0.981550000000000        0.000400000000000        0.018050000000000                          1

000055:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000056:       0.895600000000000        0.104250000000000        0.000150000000000                          1

000057:       0.795175000000000        0.000000000000000        0.204825000000000                          1

000058:       0.999900000000000        0.000100000000000        0.000000000000000                          1

000059:       0.999025000000000        0.000000000000000        0.000975000000000                          1

000060:       0.999600000000000        0.000000000000000        0.000400000000000                          1

000061:       0.999275000000000        0.000225000000000        0.000500000000000                          1

000062:       0.000075000000000        0.000000000000000        0.999925000000000                          1

000063:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000064:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000065:       0.074400000000000        0.000050000000000        0.925550000000000                          1

000066:       0.000325000000000        0.000000000000000        0.999675000000000                          1

000067:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000068:       0.000525000000000        0.000000000000000        0.999475000000000                          1

000069:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000070:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000071:       0.000075000000000        0.000000000000000        0.999925000000000                          1

000072:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000073:       0.001500000000000        0.000000000000000        0.998500000000000                          1

000074:       0.000800000000000        0.000000000000000        0.999200000000000                          1

000075:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000076:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000077:       0.001525000000000        0.000000000000000        0.998475000000000                          1

000078:       0.016925000000000        0.000000000000000        0.983075000000000                          1

000079:       0.011750000000000        0.000000000000000        0.988250000000000                          1

000080:       0.050625000000000        0.000000000000000        0.949375000000000                          1

000081:       0.006800000000000        0.000000000000000        0.993200000000000                          1

000082:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000083:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000084:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000085:       0.000075000000000        0.000000000000000        0.999925000000000                          1

000086:       0.088150000000000        0.000000000000000        0.911850000000000                          1

000087:       0.000100000000000        0.000000000000000        0.999900000000000                          1

000088:       0.080600000000000        0.000000000000000        0.919400000000000                          1

000089:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000090:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000091:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000092:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000093:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000094:       0.004325000000000        0.000000000000000        0.995675000000000                          1

000095:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000096:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000097:       0.024100000000000        0.000175000000000        0.975725000000000                          1

000098:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000099:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000100:       0.000275000000000        0.000000000000000        0.999725000000000                          1

000101:       0.000125000000000        0.000000000000000        0.999875000000000                          1

000102:       0.053750000000000        0.000000000000000        0.946250000000000                          1

000103:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000104:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000105:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000106:       0.254750000000000        0.055675000000000        0.689575000000000                          1

000107:       0.004900000000000        0.000000000000000        0.995100000000000                          1

000108:       0.172050000000000        0.000000000000000        0.827950000000000                          1

000109:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000110:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000111:       0.014800000000000        0.000000000000000        0.985200000000000                          1

000112:       0.999925000000000        0.000000000000000        0.000075000000000                          1

000113:       0.987450000000000        0.000000000000000        0.012550000000000                          1

000114:       0.999800000000000        0.000000000000000        0.000200000000000                          1

000115:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000116:       0.990400000000000        0.000075000000000        0.009525000000000                          1

000117:       0.332775000000000        0.000000000000000        0.667225000000000                          1

000118:       0.997450000000000        0.000100000000000        0.002450000000000                          1

000119:       0.937575000000000        0.000000000000000        0.062425000000000                          1

000120:       0.844525000000000        0.009325000000000        0.146150000000000                          1

000121:       0.999725000000000        0.000000000000000        0.000275000000000                          1

000122:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000123:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000124:       0.998375000000000        0.000575000000000        0.001050000000000                          1

000125:       0.954650000000000        0.045225000000000        0.000125000000000                          1

000126:       0.999875000000000        0.000125000000000        0.000000000000000                          1

000127:       0.996900000000000        0.000000000000000        0.003100000000000                          1

000128:       0.999625000000000        0.000000000000000        0.000375000000000                          1

000129:       0.294300000000000        0.000000000000000        0.705700000000000                          1

000130:       0.989625000000000        0.000000000000000        0.010375000000000                          1

000131:       0.999225000000000        0.000000000000000        0.000775000000000                          1

000132:       0.998625000000000        0.000000000000000        0.001375000000000                          1

000133:       0.999200000000000        0.000025000000000        0.000775000000000                          1

000134:       0.802125000000000        0.000050000000000        0.197825000000000                          1

000135:       0.455800000000000        0.000000000000000        0.544200000000000                          1

000136:       0.999900000000000        0.000100000000000        0.000000000000000                          1

000137:       0.580175000000000        0.000000000000000        0.419825000000000                          1

000138:       0.987175000000000        0.000000000000000        0.012825000000000                          1

000139:       0.934850000000000        0.000000000000000        0.065150000000000                          1

000140:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000141:       0.008875000000000        0.000000000000000        0.991125000000000                          1

000142:       0.939300000000000        0.000000000000000        0.060700000000000                          1

000143:       0.648175000000000        0.000100000000000        0.351725000000000                          1

000144:       0.001600000000000        0.000000000000000        0.998400000000000                          1

000145:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000146:       0.000050000000000        0.000000000000000        0.999950000000000                          1

000147:       0.000000000000000        0.000000000000000        1.000000000000000                          1

000148:       0.679750000000000        0.000725000000000        0.319525000000000                          1

000149:       0.347675000000000        0.000000000000000        0.652325000000000                          1

000150:       0.101775000000000        0.000000000000000        0.898225000000000                          1

000151:       0.905900000000000        0.000000000000000        0.094100000000000                          1

000152:       0.989725000000000        0.010000000000000        0.000275000000000                          1

000153:       0.997300000000000        0.002700000000000        0.000000000000000                          1

000154:       0.992275000000000        0.007725000000000        0.000000000000000                          1

000155:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000156:       0.999800000000000        0.000000000000000        0.000200000000000                          1

000157:       0.999975000000000        0.000025000000000        0.000000000000000                          1

000158:       0.988675000000000        0.000200000000000        0.011125000000000                          1

000159:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000160:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000161:       0.999900000000000        0.000000000000000        0.000100000000000                          1

000162:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000163:       0.999800000000000        0.000000000000000        0.000200000000000                          1

000164:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000165:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000166:       0.999700000000000        0.000300000000000        0.000000000000000                          1

000167:       0.999900000000000        0.000100000000000        0.000000000000000                          1

000168:       0.999825000000000        0.000175000000000        0.000000000000000                          1

000169:       0.999175000000000        0.000825000000000        0.000000000000000                          1

000170:       0.999750000000000        0.000200000000000        0.000050000000000                          1

000171:       0.958375000000000        0.041625000000000        0.000000000000000                          1

000172:       0.999875000000000        0.000100000000000        0.000025000000000                          1

000173:       0.999500000000000        0.000200000000000        0.000300000000000                          1

000174:       0.997075000000000        0.000625000000000        0.002300000000000                          1

000175:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000176:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000177:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000178:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000179:       0.999800000000000        0.000000000000000        0.000200000000000                          1

000180:       0.999875000000000        0.000125000000000        0.000000000000000                          1

000181:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000182:       0.999975000000000        0.000000000000000        0.000025000000000                          1

000183:       0.999675000000000        0.000325000000000        0.000000000000000                          1

000184:       0.999975000000000        0.000025000000000        0.000000000000000                          1

000185:       0.996950000000000        0.002750000000000        0.000300000000000                          1

000186:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000187:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000188:       0.999950000000000        0.000000000000000        0.000050000000000                          1

000189:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000190:       0.998275000000000        0.000000000000000        0.001725000000000                          1

000191:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000192:       1.000000000000000        0.000000000000000        0.000000000000000                          1

000193:       0.997900000000000        0.002100000000000        0.000000000000000                          1

 

Thanks for any help in advance.

Kind regards

Roy Mathew Francis

Dept. of Integrated Pest Management
Faculty of Agricultural Sciences
Aarhus University
Forsøgsvej 1
DK-4200 Slagelse

 

Tel.: +45
Email:
RoyFranc...@agrsci.dk


Tel.: +45 8999 1900
Web:
www.agrsci.au.dk

Logo

image001.jpg

romunov

unread,
Jan 14, 2011, 10:03:29 AM1/14/11
to Roy Francis Mathew, ggp...@googlegroups.com
Sounds like a the common stacking phenomena. Or have I missed something?

http://had.co.nz/ggplot2/position_stack.html

Cheers,
Roman



--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2



--
In God we trust, all others bring data.
image001.jpg

Kevin Donnelly

unread,
Jan 14, 2011, 10:28:25 AM1/14/11
to ggp...@googlegroups.com
Hi Roy

::::On Friday 14 January 2011 Roy Francis Mathew said::::


> I was wondering if its possible to create this sort of graph (result from
> structure software for population genetics) from the data below.

I'd be quite interested in the answer, because ggplot2 graphs tend to look
nicer, but it is possible to do something similar in ordinary R:
http://kevindonnelly.org.uk/2010/12/conversation-profiles/

png(filename="popgen.png", height=600, width=1000, bg="white")
par(lty=0) # To zap the normal spacing between bars
popgendata<-read.csv (file="popgendata.csv", na.strings = "NA", nrows = -1,
skip = 0, check.names = TRUE, strip.white = FALSE, blank.lines.skip = TRUE)
barplot(t(popgendata), col=c("mediumvioletred", "khaki1", "lightskyblue1"),
space=0) # Or whatever colours you like.
title(main="Population genetics data")
dev.off()

You might have to fiddle about with settings a bit until you get something you
like. Now all we have to do is wait for others to say "ggplot2 does that much
nicer - here's how ..."!

--
Pob hwyl / Best wishes

Kevin Donnelly
kevindonnelly.org.uk

Brandon Hurr

unread,
Jan 14, 2011, 10:46:45 AM1/14/11
to ke...@dotmon.com, ggp...@googlegroups.com
data<-structure(list(Sample = structure(1:39, .Label = c("000001:", 
"000002:", "000003:", "000004:", "000005:", "000006:", "000007:", 
"000008:", "000009:", "000010:", "000011:", "000012:", "000013:", 
"000014:", "000015:", "000016:", "000017:", "000018:", "000019:", 
"000020:", "000021:", "000022:", "000023:", "000024:", "000025:", 
"000026:", "000027:", "000028:", "000029:", "000030:", "000031:", 
"000032:", "000033:", "000034:", "000035:", "000036:", "000037:", 
"000038:", "000039:"), class = "factor"), Cluster.1 = c(0, 0.00075, 
0, 0, 0.00045, 5e-04, 0.102725, 0.000425, 0.070425, 0, 0, 0.011425, 
0, 0, 1, 0.088225, 0.08255, 0.000175, 2.5e-05, 0, 0, 0, 4e-04, 
0, 5e-05, 7.5e-05, 0, 0, 0.020975, 0, 0, 0, 0.2622, 0, 0.203375, 
7e-04, 0, 0.1744, 6e-04), Cluster.2 = c(1, 0.99925, 1, 1, 0.99955, 
0.9995, 0.89725, 0.999575, 0.929575, 1, 1, 0.988575, 1, 1, 0, 
0.911775, 0.9174, 0.999825, 0.999975, 1, 1, 1, 0.9996, 1, 0.99995, 
0.999925, 1, 1, 0.979025, 1, 1, 1, 0.737725, 1, 0.796625, 0.9993, 
1, 0.8256, 0.9994), Cluster.3 = c(0, 0, 0, 0, 0, 0, 2.5e-05, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 5e-05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 7.5e-05, 0, 0, 0, 0, 0, 0)), .Names = c("Sample", 
"Cluster.1", "Cluster.2", "Cluster.3"), class = "data.frame", row.names = c(NA, 
-39L))

molten.data<-melt(data)

ggplot(data=molten.data, aes(x=Sample, y=value, fill=variable))+
geom_bar()

Kind of fugly, but there are a ton of ways you can clean it up. 

Brandon


molten.graph.png

Roy Francis Mathew

unread,
Jan 14, 2011, 10:55:53 AM1/14/11
to ggp...@googlegroups.com

Thats fantastic Brandon. Thanks a lot. I think I will try to fiddle with the script and tweak it.

Thanks to Kevin and romunov for your links and replies. This group is really fast.

Med venlig hilsen / Regards
Roy Mathew Francis


--

Reply all
Reply to author
Forward
0 new messages