Can someone please show me how to draw a Swimmer plot in Stata ? This is a type a graph used in Oncology to present duration of response to treatment. Thank you.
-
Login or Register
- Log in with
* Example generated by -dataex-. To install: ssc install dataex clear input float subjectID str15 stage float(startTime endTime) str29(isContinued responseType) float(responseStartTime responseEndTime Durable) 1 "Stage 1" 0 18.5 "FilledArrow" "Complete response" 6.5 13.5 -.25 2 "Stage 2" 0 17 "" "Complete response" 10.5 17 -.25 3 "Stage 3" 0 14 "FilledArrow" "Partial response" 2.5 3.5 -.25 3 "" 0 14 "FilledArrow" "Partial response" 6 . -.25 4 "Stage 4" 0 13.5 "FilledArrow" "Partial response" 7 11 . 4 "" 0 13.5 "FilledArrow" "Partial response" 11.5 . . 5 "Stage 1" 0 12.5 "FilledArrow" "Complete response" 3.5 4.5 -.25 5 "" 0 12.5 "FilledArrow" "Complete response" 6.5 8.5 -.25 5 "" 0 12.5 "FilledArrow" "Partial response" 10.5 . -.25 6 "Stage 2" 0 12.6 "FilledArrow" "Partial response" 2.5 7 . 6 "" 0 12.6 "FilledArrow" "Partial response" 9.5 . . 7 "Stage 3" 0 11.5 "" "Complete response" 4.5 11.5 -.25 8 "Stage 1" 0 9.5 "" "Complete response" 1 9.5 -.25 9 "Stage 4" 0 8.3 "" "Partial response" 6 8.3 . 10 "Stage 2" 0 4.2 "FilledArrow" "Complete response" 1.2 . . end gen id= subjectID*(-1.2) gen cont= endTime+1 if !missing(isCon) tw (bar endTime id if regexm(stage, "1$"), hor bcolor(blue%30)) /// (bar endTime id if regexm(stage, "2$"), hor bcolor(red%30)) /// (bar endTime id if regexm(stage, "3$"), hor bcolor(green%30)) /// (bar endTime id if regexm(stage, "4$"), hor bcolor(brown%30)) /// (scatter id responseEndTime, mcolor(black)) /// (scatter id responseStartTime if regexm(responseType, "^C") , /// sym(triangle) mcolor(red) ) (scatter id responseStartTime if /// regexm(responseType, "^P") , sym(triangle) mcolor(blue)) /// (pcarrow id endTime id cont, mcolor(black) barbsize(2) lcolor(black)) /// (scatter id Durable, sym(square) mcolor(black) ylab("", noticks) xsc(r(-1,.)) /// xlab(0/20) scheme(s1color) xtitle("Months") ytitle("Subjects Received Study Drug") /// leg(off) note("Each bar represents one subject in the study." /// "A Durable Responder is a subject who has confirmed response for at least 183 days (6 months)"))
gen id= newid*(1.2)
* Example generated by -dataex-. For more info, type help dataex
clear
input float subjectID str15 stage float(startTime endTime)
7 "Stage 1" 0 18.5
5 "Stage 2" 0 17
1 "Stage 3" 0 14
1 "" 0 14
10 "Stage 4" 0 13.5
10 "" 0 13.5
2 "Stage 1" 0 12.5
2 "" 0 12.5
2 "" 0 12.5
3 "Stage 2" 0 12.6
3 "" 0 12.6
4 "Stage 3" 0 11.5
6 "Stage 1" 0 9.5
8 "Stage 4" 0 8.3
9 "Stage 2" 0 4.2
end
egen newid= group(endTime subjectID)
. l, sep(0) +-------------------------------------------------+ | subjec~D stage startT~e endTime newid | |-------------------------------------------------| 1. | 7 Stage 1 0 18.5 10 | 2. | 5 Stage 2 0 17 9 | 3. | 1 Stage 3 0 14 8 | 4. | 1 0 14 8 | 5. | 10 Stage 4 0 13.5 7 | 6. | 10 0 13.5 7 | 7. | 2 Stage 1 0 12.5 5 | 8. | 2 0 12.5 5 | 9. | 2 0 12.5 5 | 10. | 3 Stage 2 0 12.6 6 | 11. | 3 0 12.6 6 | 12. | 4 Stage 3 0 11.5 4 | 13. | 6 Stage 1 0 9.5 3 | 14. | 8 Stage 4 0 8.3 2 | 15. | 9 Stage 2 0 4.2 1 | +-------------------------------------------------+
Comment