Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • graph combine memory graph not working with include do.files

    Hello,

    I am trying plot stcurves condensing the code for generating underlying numbers to be displayed on the graph as two include files. The graph combine seems to stop working since my saving option is not a memory graph. How do I fix the issue?
    I have included my main code and the two underlying include files (for generating median and overall survival). It has something to do with my graph save options. I have played with all possible options in the help sections but am hitting a wall now. I am able to combine easily without the include do files.


    Code:
    **# Fig_2AB anymds_monosomy
    
    local x anymds                                        // assign the local to the variable to be modeled.
    local title "OS24 by prior MDS"
    local 0val "No prior MDS"
    local 1val "Prior MDS"
    include ".\stpm2graph.do"
    
    /*plot survival curve from model*/
    include ".\coxgraph.do"  
    graph save test, replace
    
        
    # Graph stcurve by monosomies
    local x mono2                                        // assign the local to the variable to be modeled.
    local title "OS24 by sutosomal monosomies"
    local 0val "0-1 Monosomies"
    local 1val "2+ Monosomies"
    include ".\stpm2graph.do"
    
    /*plot survival curve from model*/
    include ".\coxgraph.do"              
            graph save test2, replace
    
    
    **# Fig 2 combine
    graph combine test test2, cols(2) ycommon xcommon altshrink
        graph export ".\A_UOC academic\Project Amandeep TP53\Manuscript TP53\Assets\Fig 02_stc_anymds_mono.png",     ///
        width(4800) height(2000) replace as(png)
    Initial stpm2graph.do for the overall survival numbers
    *--------------------------------------------------------------------
    Code:
    qui stpm2 i.`x' i.age70, df(4) eform scale(h)
    range tt 1 24 24
    predict ms0, meansurv ci timevar(tt) at(`x' 0)
    predict ms1, meansurv ci timevar(tt) at(`x' 1)
    
    // List the values
    list tt ms0 ms1 in 24
    
    // Save ms00 and ms10 to local macros as percentages
    local ms0_val = string(round(ms0[24] * 100, 0.1), "%9.1f") + "%"
    local ms0_v = ms0[24]
    local ms1_val = string(round(ms1[24] * 100, 0.1), "%9.1f") + "%"
    local ms1_v = ms1[24]
    stcox ib0.anymds ib0.age70
    
    stcox ib0.`x' ib0.age70
    matrix list r(table)
    scalar b = round(r(table)[1,2], 0.01)
    local b = scalar(b)
    scalar l = round(r(table)[5,2], 0.01)
    local l = scalar(l)
    scalar u = round(r(table)[6,2], 0.01)
    local u = scalar(u)
    local p = round(r(table)[4,2], 0.0001)
    
    drop ms0* ms1* tt _rc* _d_*

    // Include coxgraph file condensed for binary variables for p53 paper

    Code:
    stcurve, surv at1(`x'= 0) at2(`x' = 1) scheme(s2color)                                     ///
        lcolor(dkorange cranberry) lpat(solid solid)                                          ///
        graphregion(margin(vsmall) icolor(white) color(white) )                             ///
        title("`title'", size(medium)) bcolor(black)                                         ///
        subtitle("After adjusted P-H regression* ({it:n}= `e(N)')", size(small))             ///
        note("*Adjusted for age", span size(small))                                         ///
        caption("OS24 derived from flexible parametric model with 4 degrees of freedom with underlying age as the time scale", span size(small))                                                                                         ///
        xtitle("Time since Diagnosis (months)", size(small))                                 ///
        xlabel(0(2)26, labs(small)) ylabel(0(0.25)1, angle(0) labs(small))                     ///
        ylabel(0 .5  1)                                                                        ///
        ytitle("Proportion surviving", size(small) margin(medium))                             ///
        legend(order(1 "`0val'" 2 "`1val'")                                                 ///
        col(1) size(small) symxsize(*0.5) margin(small) rowg(*0.1) ring(0) pos(1) region(lcolor(white)))             ///
        text(.75 15 "Model {it:p} = `p'" "HR `b' [95% CI: `l'-`u']" ,place(c) nobox just(left) margin(l+1 t+1 b+1) width(65) size(medium))                     ///
        text(`ms0_v' 25.1 "`ms0_val'" ,place(c) nobox just(center) margin(l+1 t+1 b+1) width(65) size(small)) ///    
        text(`ms1_v' 25.1 "`ms1_val'" ,place(c) nobox just(center) margin(l+1 t+1 b+1) width(65) size(small))
    Last edited by Girish Venkataraman; 12 May 2023, 07:44. Reason: Title more clear now.

  • #2
    -graph save- does not store the graph in memory; it stores it on your drive. -graph combine- only works with graphs stored in memory. So, instead of -graph save test-, run -graph rename test-. Similarly for test2. That will enable -graph combine- to find these graphs.

    Comment


    • #3
      Clyde Schechter graph combine does work with graphs saved to disk - but you have to provide the full name of the file including the extension - there is an example in the help file under "typical use"; see
      Code:
      h graph combine

      Comment


      • #4
        Thanks, Rich. I didn't know that.

        Comment


        • #5
          Originally posted by Clyde Schechter View Post
          -graph save- does not store the graph in memory; it stores it on your drive. -graph combine- only works with graphs stored in memory. So, instead of -graph save test-, run -graph rename test-. Similarly for test2. That will enable -graph combine- to find these graphs.
          Thanks a ton. That worked!!

          Rich Goldstein, your method worked like a breeze too. I am going to stick with Clyde's solution for now since its less typing.

          Comment

          Working...
          X