# mouse

How to download and try this example

    Usage: pl -gif mouse.htm

    Uses data file mouse.dat.

    #declare BINSIZE soft
    #declare RECT

    #declare LL A1 A2 A3 A4

    ///////////// get plot data
    #proc getdata
      file: mouse.dat
    fieldnames: strain sex var mean stderr n stddev

    /////////////  no data.. exit
    #proc endproc
    #if @NRECORDS = 0
      #proc annotate
      location: 3 3
      text:	No data found that
    	corresponded to your request.

      #exit
    #endif

    ///////////// set up plotting area for strains comparison bars
    #proc areadef
    rectangle: 1 1 8 3
    autowidth: 0.1 3.5 15
    xscaletype: categories
    xcategories: datafield=1
    catcompmethod: exact
    xaxis.axisline: none
    xaxis.stubs: usecategories
    xaxis.stubvert: yes
    xaxis.gridblocks: gray(0.9) white
    xaxis.gridlineextent: min-0.5 max
    xaxis.stubslide: -0.5(s)
    xaxis.stubdetails: adjust=0,0.1 size=6
    xaxis.tics: none
    yautorange: datafield=mean
    yaxis.stubs: inc
    yaxis.stubcull: yes
    yaxis.stubdetails: size=6
    yaxis.labeldetails: adjust=-0.1,0 size=8

    /////////// do overall mean and sd for background
    #proc rangebar
    meanmode: yes
    datafield: mean
    statsonly: yes

    // +/- 1 SD line (thin)
    #proc line
    notation: locval
    linedetails: color=teal width=0.3 style=1
    points: min @RANGEBARMAX(s) max @RANGEBARMAX(s)
    	min @RANGEBARMIN(s) max @RANGEBARMIN(s)

    // overall mean line (thicker)
    #proc line
    notation: locval
    linedetails: color=teal width=1 style=1
    points: min @RANGEBARMEAN(s) max @RANGEBARMEAN(s)

    // legend entry for the mean and +/- 1 SD line
    #proc legendentry
    sampletype: line
    details: color=teal width=1 style=1
    label: Overall mean and +/- 1 SD

    //////////// blue bars for males..
    // always since it is #saved for later cloning (but may not always draw)
    #proc catslide
    axis: x
    amount: -0.65

    #proc bars
    locfield: strain
    lenfield: mean
    errbarfields: stderr
    ticlen: 0.03
    select: @@sex like m*
    tails: 0.03
    thinbarline: color=blue width=0.4
    truncate: yes
    legendlabel: Male
    #saveas B

    // do mean tics in a separate step to allow for means-only data sets e.g. mogil pain
    #proc scatterplot
    xfield: strain
    select: @@sex like m*
    yfield: mean
    linelen: 0.04
    linedetails: color=blue width=0.4

    ////////////// red bars for females..
    #proc catslide
    axis: x
    amount: -0.35

    #proc bars
    #clone B
    select: @@sex like f*
    thinbarline: color=red width=0.4
    legendlabel: Female

    #proc scatterplot
    xfield: strain
    select: @@sex like f*
    yfield: mean
    linelen: 0.04
    linedetails: color=red width=0.4

    ////////////////// now display the legend..
    #proc legend
    location: min+0.5 max+0.2
    format: singleline
    sep: 0.7
    seglen: 0.25
    textdetails: size=6

    /////////////////////////////////////////////
    // do a distribution plot in a separate .gif file..
    /////////////////////////////////////////////
    #proc page
    tightcrop: yes

    #set RECT = "1 1 3 1.5

    #proc areadef
    rectangle: @RECT
    xautorange: datafield=mean
    yrange: 0 100   // to be revised after we run the distribution..
    #saveas A

    #proc xaxis
    stubs: inc
    stubcull: 0.25
    stubdetails: size=6
    label: measurement value
    labeldetails: size=6 adjust=0,0.1

    #proc endproc
    #set BINSIZE = $arith(@XINC/2)

    // tabulate the distribution of values, e.g. how many strains fell into each bin
    #proc tabulate
      datafield1: mean
      doranges1: yes
      rangespec1: @XMIN @BINSIZE
      // savetable: stderr
      showrange: avg

    // check for degenerate case of all 0 freqs..  if so display message and exit..
    #proc print
    select: @@2 > 0.0

    #proc endproc
    #if @NSELECTED < 1
      #proc annotate
       location: 2 1.35
       textdetails: size=6
       text: Not available...
    	 Try male only or female only.

      #exit
    #endif

    // now that we have the distribution, recompute the plotting area with a auto Y range
    #proc areadef
    rectangle: @RECT
    yautorange: datafield=2
    xrange: @XMIN @XMAX

    #proc yaxis
    stubs: inc
    stubcull: 0.12
    stubdetails: size=6
    label: N strains
    labeldetails: size=6 adjust=0.1,0

    #proc curvefit
    curvetype: bspline
    xfield: 1
    yfield: 2
    order: 5
    linedetails: color=gray(0.5) width=0.5

    #proc bars
    locfield: 1
    lenfield: 2
    barwidth: 0.04
    color: pink
    outline: no
    hidezerobars: yes

    #proc annotate
    location: min-0.1 min-0.3
    textdetails: size=6
    text: Bins = @BINSIZE