cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Thierry_S
Super User

WINDOWS 10 > JMP 17.2 > Graph Builder > Scatter Plot > Dynamic Cluster Annotation

Hi JMP Community,

 

Windows Pro 10 - JMP 17.2

 

I have some data projected on a 2D UMAP, and I would like to automatically insert the formatted (Color and Size) Cluster ID on top of the UMAP2 x UMAP1 Scatter Plot in Graph Builder. I managed to get the Cluster IDs by plotting them separately and merging them to the main FrameBox. Still, this is unsatisfactory because I cannot control the size and color of those Cluster ID labels.

 

I experimented with a Loop within an Add Graphics Script() command but could not make it work.

 

Thierry_S_0-1735364165556.png

Here is the script I used to produce the plot above

Names Default to Here(1);

dt = Data Table ("ANNOTATION of 2D CLUSTERS");

dt_sum = dt << Summary(
	Group( :WARD UMAP CLUSTERS ),
	Mean( :UMAP1 CENTER by CLUSTER ),
	Mean( :UMAP2 CENTER by CLUSTER ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" )
);

gb = dt << Graph Builder(
				Size( 483, 675 ),
				Fit to Window( "Off" ),
				Page Level Fill Color( "White" ),
				Graph Spacing( 15 ),
				Spacing Borders( 1 ),
				Variables( X( :UMAP1 ), Y( :UMAP2 ), Color( :WARD UMAP CLUSTERS ) ),
				Elements( Points( X, Y, Legend( 27 ) ) )
			);

gbr = report (gb);

main_x_max = gbr [AxisBox(1)] << Get Max;
main_x_min = gbr [AxisBox(1)] << Get Min;

main_y_max = gbr [AxisBox(2)] << Get Max;
main_y_min = gbr [AxisBox(2)] << Get Min;

F_size = gbr[FrameBox(1)] << Get Size;

xbe = Expr(dt_sum << Graph Builder(
			Size( _W_, _H_ ),
			Fit to Window( "Off" ),
			Page Level Fill Color( "White" ),
			Graph Spacing( 15 ),
			Spacing Borders( 1 ),
			Variables(
				X( :UMAP1 CENTER by CLUSTER ),
				Y( :UMAP2 CENTER by CLUSTER ),
				Color( :WARD UMAP CLUSTERS )
			),
			Elements(
				Bar( X, Y, Legend( 4 ), Bar Style( "Float" ), Label( "Label by Row" ) )
			)
		)
	);	
xbx = Substitute(Name Expr (xbe), 	Expr (_W_), F_Size [1],
									Expr (_H_), F_size [2]
);

xb = Eval (xbx);

xbr = report (xb);

xbr [AxisBox (1)] << max (main_x_max);
xbr [AxisBox (1)] << min (main_x_min);	

xbr [AxisBox (2)] << max (main_y_max);
xbr [AxisBox (2)] << min (main_y_min);

xbr [FrameBox(1)] << Copy Frame Contents;
gbr [FrameBox(1)] << Paste Frame Contents;

Thank you.

Best,

TS

 

Thierry R. Sornasse
2 REPLIES 2
jthi
Super User

Re: WINDOWS 10 > JMP 17.2 > Graph Builder > Scatter Plot > Dynamic Cluster Annotation

You could add "extra" x and y-axis and then use those. Note that the color has been changed for the Mean(UMAP2) as it cannot be left as default or they will use Value Colors. You can also change the marker size to 0 i you don't want to highlight the "mean" point or change the marker

jthi_0-1735367411861.png

 

Graph Builder(
	Size(438, 629),
	Show Control Panel(0),
	Fit to Window("Off"),
	Page Level Fill Color("White"),
	Graph Spacing(15),
	Spacing Borders(1),
	Variables(
		X(:UMAP1),
		X(:UMAP1 CENTER by CLUSTER, Position(1)),
		Y(:UMAP2),
		Y(:UMAP2 CENTER by CLUSTER, Position(1)),
		Color(:WARD UMAP CLUSTERS)
	),
	Elements(
		Points(X(1), Y(1), Legend(27)),
		Points(
			X(2),
			Y(1),
			Color(0),
			Legend(32),
			Summary Statistic("Mean"),
			Label("Label by Row")
		)
	),
	SendToReport(
		Dispatch({}, "400", ScaleBox,
			{Legend Model(
				32,
				Properties(0, {Line Color(16)}, Item ID("Mean(UMAP2)", 1))
			)}
		)
	)
);

 

-Jarmo
Thierry_S
Super User

Re: WINDOWS 10 > JMP 17.2 > Graph Builder > Scatter Plot > Dynamic Cluster Annotation

Hi Jarmo,

Thank you for providing a much simpler solution to my initial challenge. Still, I would like to change the Labels' Font Size and Color to make the plot more readable. Do you have any clues on how I could achieve that task?

 

Best regards,

TS

 

Thierry R. Sornasse