Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- JMP User Community
- :
- Discussions
- :
- Re: Graph Builder Add p Values dynamically: recommended workflow

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Feb 29, 2020 4:12 PM
(1576 views)

Hi JMP community,

I often need to annotate Graph Builder plots (~200) with the results of an analysis (e.g. p Values. Estimates). So far, I have mostly relied on manual annotations but I'm starting to be tired of this approach. I know how to add text dynamically via scripting but I have not figured out a good way to solve my specific problem (see below)

What would be your recommended workflow in the following case:

__Graph Data__: ~200 columns containing the Y values (~1,000 rows); X data define in 1 column, Overlay data in 1 column, yielding 200 plots

__Analysis results__: 1 row per Y value, columns containing the p Value, Estimates, and other possible analysis outputs.

__Note__: Automation has been challenging because the initial data is always slightly different from one batch to another.

My main problem is that the __graph data__ and __analysis results__ tables are organized orthogonally (Y in columns vs. Y in rows) which would require transposing the result table, split the resulting table by analysis outputs (p Values, Estimates,...) and connect the resulting table to the Graph Table. This does not seem very efficient so any suggestions would be welcome.

Thank you.

TS

Thierry R. Sornasse

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

I'm sure everyone would approach this slightly differently. But if the two tables above are your starting point, then I would do something like this:

```
NamesDefaultToHere(1);
// Data tables
data = DataTable("Test WORKFLOW.jmp");
stats = DataTable("Test WORKFLOW RESULT TABLE.jmp");
// Template expression for Graph Builder with text annotation
gbExpr =
Expr(
data << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :X ), Y( yTBD ), Overlay( :Overlay ) ),
Elements(Line(X, Y, Legend( 12 ), Error Interval( "None" ))),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Graphics Script( 2, Description( "Annotation" ), Text( {8, 0}, "interaction P Val: "||Char(Round(pValTBD, 3))))}
)
)
)
);
// Loop over 'Y' variables
lub = LineUpBox(NCol(1));
for(c=3, c<=NCol(data), c++,
yCol = Column(data, c);
pVal = Column(stats, 2)[c-2];
lub << append(Eval(Substitute(NameExpr(gbExpr), Expr(yTBD), yCol, Expr(pValTBD), pVal)));
);
// Reports in a Journal
nw = NewWindow("Report", <<Journal, lub);
```

You should be able to develop this outline to suit your case. You could also try including some logic to place the annotation in a 'better' place. If you are not sure how it works, then see 'Help > Scripting Guide' and the JSL book.

3 REPLIES 3

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Graph Builder Add p Values dynamically: recommended workflow

Generally, JMP makes rearranging data easy, and 'inefficient' is a relative term. If I understand correctly, you want to add some results from one (analysis) platform to those from another (graphical) platform. The best workflow will depend on the details.

The script below makes some random data in line with what you say above. If you could run it, then post the script that will reproduce the results from your two chosen platforms, folks will be better able to give more specific recommendations.

```
NamesDefaultToHere(1);
// Make a data table
nr = 1000;
y = J(nr, 200, RandomNormal());
x = J(nr, 1, RandomUniform(1, 10));
o = J(nr, 1, RandomInteger(1, 6));
dt = AsTable(x||o||y);
dt << setName("Test");
Column(dt, 1) << setName("X");
Column(dt, 2) << setName("Overlay");
```

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Graph Builder Add p Values dynamically: recommended workflow

Find attached 3 files:

- Input data table as generated with your script (minor modification)
- An example of OUTPUT table
- An Example of PLOTS journal

Thank you for looking into this.

Best regards,

TS

Thierry R. Sornasse

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

I'm sure everyone would approach this slightly differently. But if the two tables above are your starting point, then I would do something like this:

```
NamesDefaultToHere(1);
// Data tables
data = DataTable("Test WORKFLOW.jmp");
stats = DataTable("Test WORKFLOW RESULT TABLE.jmp");
// Template expression for Graph Builder with text annotation
gbExpr =
Expr(
data << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :X ), Y( yTBD ), Overlay( :Overlay ) ),
Elements(Line(X, Y, Legend( 12 ), Error Interval( "None" ))),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Graphics Script( 2, Description( "Annotation" ), Text( {8, 0}, "interaction P Val: "||Char(Round(pValTBD, 3))))}
)
)
)
);
// Loop over 'Y' variables
lub = LineUpBox(NCol(1));
for(c=3, c<=NCol(data), c++,
yCol = Column(data, c);
pVal = Column(stats, 2)[c-2];
lub << append(Eval(Substitute(NameExpr(gbExpr), Expr(yTBD), yCol, Expr(pValTBD), pVal)));
);
// Reports in a Journal
nw = NewWindow("Report", <<Journal, lub);
```

You should be able to develop this outline to suit your case. You could also try including some logic to place the annotation in a 'better' place. If you are not sure how it works, then see 'Help > Scripting Guide' and the JSL book.

Article Labels

There are no labels assigned to this post.