cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Thierry_S
Super User

Graph Builder Add p Values dynamically: recommended workflow

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
ian_jmp
Level X

Re: Graph Builder Add p Values dynamically: recommended workflow

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.

View solution in original post

3 REPLIES 3
ian_jmp
Level X

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");
Thierry_S
Super User

Re: Graph Builder Add p Values dynamically: recommended workflow

Find attached 3 files:

  1. Input data table as generated with your script (minor modification)
  2. An example of OUTPUT table
  3. An Example of PLOTS journal

Thank you for looking into this.

Best regards,

TS

Thierry R. Sornasse
ian_jmp
Level X

Re: Graph Builder Add p Values dynamically: recommended workflow

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.