Announcement

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

  • Bootstrap as manual

    Hi,

    I'm studying bootstrap for microarray analysis. I found this code from http://www.compgen.org/tools/microarrays

    Code:
    program define ttestboot, rclass
    version 10.1
        syntax , x(varlist numeric max=1) type(varlist numeric max=1) [ reps(real 100) var(string )  ]
    set more off
    
    di in ye "______________________________________________________________________________"
    
    di in ye "   Calculation of Achieved Significance Level (ASL) using the bootstrap"
    di in ye "   The idea is to recenter the two samples to the combined sample mean"
    di in ye "   so that the data now conform to the null hypothesis but that the"
    di in ye "   variances within the samples remain unchanged"
    di in ye "______________________________________________________________________________"
    
    preserve
    ttest `x',by(`type') uneq
    tempname tobs omean
    scalar `tobs' = r(t)
    qui summarize `x', meanonly
    scalar `omean' = r(mean)
    qui summarize `x' if `type'==0, meanonly
    qui replace `x' = `x' - r(mean) + scalar(`omean') if `type'==0
    qui summarize `x' if `type'==1, meanonly
    qui replace `x' = `x' - r(mean) + scalar(`omean') if `type'==1
    tempfile boot
    
    bootstrap t=r(t),nolegend nowarn notable reps(`reps') strata(`type') saving(`boot'): ttest `x',by(`type') `var'
    
    use `boot',clear
    qui generate indicator = abs(t)>=abs(scalar(`tobs'))
    qui summarize indicator, meanonly
    display in ye "ASLboot = " r(mean)
    restore
    return scalar p=r(mean)
    end
    I have a gene expression data which has 10 Treatment and 10 control samples with 250 genes. I converted it vectorized format. For example:
    Gene Exp Type
    Gene1 1.602014 1=treat
    Gene1 1.497501 0=control
    Gene2 1.675608 1
    Gene2 3.727904 0
    When I run this code for this table I 'm getting this error:



    Code:
    ttestboot Expr Type [reps(100) Gene]
    #varlist not allowed
    I guess I don't know and understand calling program. I described list object with this command:

    Code:
    list Expr Type Gene
    How can I call ttestboot ? Can you suggest something or share knowledge?

  • #2
    Based on line 3, the arguments you provided should be treated as options. Try something like this to start:

    Code:
    ttestboot, x(Expr) type(Type) reps(100)

    Comment


    • #3
      Thank you for ypur response. it is working now, but only one t obs. was produced. we can see all genes with type. My aim is to find expressed genes. In this code var(string ) can be genes?
      Last edited by Akya Nus; 09 Apr 2021, 06:48.

      Comment


      • #4
        I have not worked with this command but from what I understand that "var(string)" is reserved for the option items specific to the -ttest- command. See -help ttest- and look under "option 1" in the syntax chart.

        If you want to repeat that by Gene, I'd suggest:

        Code:
        bysort Gene: ttestboot, x(Expr) type(Type) reps(100)

        Comment


        • #5
          Thank you I will check.

          Comment


          • #6
            I tried some options from help, but I got an error.


            HTML Code:
            by gene, sort : ttestboot, x(Expr) type(Type) reps(100)
            ttestboot may not be combined with by

            Comment


            • #7
              Originally posted by Akya Nus View Post
              I tried some options from help, but I got an error.
              HTML Code:
              by gene, sort : ttestboot, x(Expr) type(Type) reps(100)
              ttestboot may not be combined with by
              I'm just going off on guesses here. First, try "if". For example:

              Code:
              ttestboot if Gene == "Gene1", x(Expr) type(Type) reps(100)
              If it still doesn't work, then you may have to subset the data using -keep- and then apply the code.

              Both of them may require some looping depending how many gene types are there, check -foreach- to learn more.

              Good luck!

              Comment

              Working...
              X