Hi All, I'm helping a friend with a project and agreed (foolishly) to help her with some graphs. She wants to combine a bar graph with a dot plot for to show the individual data points and for the bar graph to show the mean for each group.
Here is the data
To explain the context that was a small study where 4 patients (patient ids listed in variable "patient") where tested for various cell markers (listed in variable "cell") in samples from either blood or tissue grafts (listed in variable "type")
Because I needed to create 8 distinct groups for her graph I used concat
and then encoded the variable to numeric
So she essentially wants a bar graph overplayed with a dot plot, but she also wanted every patient to have a unique marker so I opted to use "graph dotplot" rather than "graph dot" because with graph dot plot I can specify specific markers for each value of pt
Essentially this:
So I can generate the dot plot
and generate the bar graph
but I cannot overlay one on the other because dotplot is not a two-way graph type.
Thus after my long introduction, my question is basically is there some way to overlay these graphs one on the other. Failing that, does anyway know how I can specify marker options for the regular graph dot such that every patient has unique marker. This doesn't seem to be an option for graph dot as it is for dotplot.
Much thanks in advance. Using Stata v13
Best,
Chris
Here is the data
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int pt double value str5 type str6 cell 107 .39823008849557523 "blood" "CD69" 106 . "blood" "CD69" 101 .3185840707964602 "blood" "CD69" 11 .7441860465116279 "blood" "CD69" 107 .9407407407407408 "graft" "CD69" 106 . "graft" "CD69" 101 .6619718309859155 "graft" "CD69" 11 .7857142857142857 "graft" "CD69" 107 .5803571428571429 "blood" "CD45RA" 106 .7317073170731707 "blood" "CD45RA" 101 .5398230088495575 "blood" "CD45RA" 11 .3488372093023256 "blood" "CD45RA" 107 .08148148148148149 "graft" "CD45RA" 106 .1111111111111111 "graft" "CD45RA" 101 .4788732394366197 "graft" "CD45RA" 11 .2857142857142857 "graft" "CD45RA" 107 .36607142857142855 "blood" "CD45RO" 106 .18699186991869918 "blood" "CD45RO" 101 .23008849557522124 "blood" "CD45RO" 11 .6046511627906976 "blood" "CD45RO" 107 .8 "graft" "CD45RO" 106 .8395061728395061 "graft" "CD45RO" 101 .22535211267605634 "graft" "CD45RO" 11 .6190476190476191 "graft" "CD45RO" 107 .03571428571428571 "blood" "CTLA4" 106 0 "blood" "CTLA4" 101 0 "blood" "CTLA4" 11 0 "blood" "CTLA4" 107 .362962962962963 "graft" "CTLA4" 106 .06172839506172839 "graft" "CTLA4" 101 .07746478873239436 "graft" "CTLA4" 11 .14285714285714285 "graft" "CTLA4" end
Because I needed to create 8 distinct groups for her graph I used concat
Code:
egen group =concat(cell type)
Code:
rename group _group encode _group, gen(group) drop _group
Essentially this:
Code:
label define symbol 107 "o" 106 "x" 101 "+" 11 "*" label values pt symbol
Code:
dotplot value, over(group) m(none) mlabel(pt) xlabel( 1 `""CD45RA" "blood""' 2 `""CD45RA" "graft""' 3 `""CD45RO" "blood""' 4 `""CD45RO" "graft""' 5 `""CD69" "blood""' 6 `""CD69" "graft""' 7 `""CTLA4" "blood""' 8 `""CTLA4" "graft""') xtitle("")
Code:
graph bar (mean) value, over(group, relabel( 1 `""CD45RA" "blood""' 2 `""CD45RA" "graft""' 3 `""CD45RO" "blood""' 4 `""CD45RO" "graft""' 5 `""CD69" "blood""' 6 `""CD69" "graft""' 7 `""CTLA4" "blood""' 8 `""CTLA4" "graft""'))
Thus after my long introduction, my question is basically is there some way to overlay these graphs one on the other. Failing that, does anyway know how I can specify marker options for the regular graph dot such that every patient has unique marker. This doesn't seem to be an option for graph dot as it is for dotplot.
Much thanks in advance. Using Stata v13
Best,
Chris
Comment