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

Creating a Custom Report

Started ‎11-08-2022 by
Modified ‎10-12-2023 by
View Fullscreen Exit Fullscreen

Learn more in our online course with
videos, practice exercises & quizzes.
Select and take the lessons in any order.
Introduction to the JMP Scripting Language

 

In this demonstration, we'll use a pre-written script to see how to make a custom report. So in the course journal, in section there's a script called NOx data for the nitrogen oxide data. And we have six different preparations. And then we've recorded the log of the concentration of the nitrogen oxide for each of the replicates of the six different preparations. So the script is pre-written. And in the course journal, it's called Custom NOx Report Script. And I'm going to run this piece by piece. But I actually want to run the entire thing so we can see the final result before we go through and look at what each part of the script does. So I'll run the entire thing. This script does create a summary table that's used in the Graph Builder. We'll go through that so we're not just using the raw data. But the Custom Report is a tabbed report. On the first tab, called %CV, we have that live Graph Builder platform. So this red triangle is the typical red triangle menu I would see in the Graph Builder. And then, we have the computed coefficients of variation or %CV for each level. And here, we have a custom red triangle menu that our script created that allows me to specify the number of decimal places I want for the number columns within my report. And on the second tab, called Background Information, I've got the raw data for each level, the mean and standard deviation that are used to compute the coefficient of variation, and the computed value. And if I made a selection in that red triangle menu-- which actually I'll just do. In %CV, the front tab, I'll go to the red triangle and select two decimals. The script is looking at all of the number column boxes in this report. So let's take a look at how it was constructed. So the first thing that the script does is it sends the one-way message to the original data table with the log of the nitrogen oxide-- log of the concentration of the nitrogen oxide in the Y role and the preparation in the X role. And what I need to compute the coefficient of variation is the means and standard deviation report table. So I request that be turned on. I'll mention that there are many ways that I could get the coefficient of variation from JMP without calculating it by hand. But we're, again, illustrating some of the ideas of getting values as a matrix and using those matrix computations. So I'll run lines through And here's the one-way output with the table that I requested. Now, in line we see that other syntax for getting the report layer. And an advantage of using this syntax is that if I don't need everything that's in that report, I can simply request, in this case, the outline item for the table that I want-- the means and standard deviations. So that I can simplify my code a little bit when I'm accessing display boxes. And I'll store that in the variable ob. Here, our convention is simply using the abbreviation for outline box. And you saw when I hovered, it already is storing a value, because I already ran the whole script. But I'm going to reassign that. Now, lines and are retrieving the column of the levels, and then the columns of the means and standard deviations. For the levels, I don't need to manipulate the values in this column at all. I'm just going to want that in my custom report for the Estimates table, and in the background information-- the All Results table. So a neat thing that I can do with a display box that I just need a copy of is send the message "clone box." And that's just going to store a clone of this display box in Levels, even after I close the one-way window. So we subscript the variable ob with String Col Box Now here, again, we could use the column headers, and it wouldn't hurt to do that, certainly. But because we have just this one display box stored in-- or the reference to it stored in ob, it's easy enough to use the simple syntax with the index values. So I'll run line And so Levels is now storing a display box, and specifically a string column box you can see here in the log. Line I need to use the means and standard deviations in computation. So I can't simply have a copy of those. I need to get the values as a matrix and store them in the variable mMeans, or matrix of means. And you can see in the log, or if you hover over mMeans what those values are. And the same thing in line for the standard deviations. So I run that, and again, you can-- I'll make this little smaller-- you can see in the log those values. Line creates a variable called mCVs, and that's just the calculation for that coefficient of variation again. That's a relative measure of variability where we divide the standard deviations by the means and then multiply that by So I'll run line So now I have the coefficients of variation. And at this point, I don't need anything else from the platform. So I'm going to send the message to ow-- this is sent to the analysis layer object reference-- to close that window. And I always recommend, when your script can close windows, whether it's analyses or data tables that are no longer needed, go ahead and have your script close those windows. Because if we don't need them to be open any longer, we don't need them to be taking up memory. Now for the next step, I wanted to use the Graph Builder in my custom report. And the Graph Builder does not currently calculate coefficient of variation as one of its summary statistics. So the workaround was to create this summary table with the coefficient of variation, which is built-in in the Summary Tables command, and then use that as the basis for the Graph Builder. So before I get the Summary table, I want to close the one that showed up when I ran the entire script. And when I close that, I get the warning there's another window open, so I'm going to say, go ahead and close all. And that immediately removed the Graph Builder from my custom report. So at this point, there's not really any reason to keep this example custom report open. We're going to recreate it as we continue through the script. So I'll close that one as well. So line sends "Summary" as the message to the original data table, where we group up by preparation. And the statistic will be that coefficient of variation. So I'll run line And now, I have everything I need to construct my custom report. So we use New Window. And I'm going to store the display box that's created by this in the variable nw so I can communicate with it. I title my new window Custom Report, and then I want to script those tabs. So we specify Tab Box. And then the number of tabs is just determined by how many tab page box arguments you supply to that. So we'll have in this case. The first argument to Tab Page Box is the title. And so the first one is called %CV. And then, H List Box gives me a horizontal list box that will contain the Graph Builder. And so I'm actually launching that live. That's how I get this live platform in this window is by having that launch just occur in the display box. This is syntax I might have grabbed from interactively creating the Graph Builder and sending it to the Summarize table. And then, the other thing I'm lining up in the H List Box is the outline box, called Estimates, which is going to have the table box containing the string column box stored in Levels. And my script creates a number column box with the %CV values. The second tab page box is the background information, using an outline box to label it as All Results. And within the outline box, a table box lines up four number column boxes horizontally. So I'm going to make this taller just so I can make sure I grab the lines I want, which are through And I'll run that portion. So this is not complete. This is the starting place for my custom report. And I think I can make the script window a little narrower now so we can see both side by side. So Graph Builder does not, by default, have a line at so that's one of the things I want to add. I want to resize it, because I don't need the graph to be this big. And I want to add that red triangle menu to the Estimates outline item. Notice, in the script, when I created the outline box of the estimates on the first tab of the custom report, I stored that result in ob. And that was a variable name I'd used earlier when I was getting the means and standard deviations from the one-way platform. So here again, I simply used the abbreviation and overwrote that value because I didn't need the previous value. So if I scroll down now to see the remainder of the script, I'm sending a message "Set Menu Script" to the display box stored in ob, which is that Estimates outline box. And Set Menu Script takes as its argument a list of menu items alternating with the expression that executes when that menu item is selected. So the expression is simply looping through the number column boxes in the report and setting the format. We have a field width of maximum number of characters that can be displayed-- and then the number of decimal places. So depending on which of those red triangle menu options we select, that determines which of these expressions will execute. So I'm going to run lines through And in the custom report, you see now that we have the red triangle menu. Line is going to change the size of the frame box from the Graph Builder. And this is something that, if I went to-- I'm going to right click on the Disclosure button, and under Edit, select Show Tree Structure-- I could scroll down. When you're looking at an entire report, there's a lot of constructors in here that we don't use when we're writing our own scripts. But I scroll down. OK, there's PictureBox, scroll down some more, there's that title, scroll down some more. You can hover to see the axis boxes. And finally, I see the FrameBox, and so I can see that that's the thing that I want to resize is As you become familiar with platforms, you may not need to look at the tree structure. So line I subscript the new window with and send the message "Frame Size," which is by pixels, and I'll go ahead and run line So that resized that Graph Builder frame box. Now again, you can use the scripting index to look at what kinds of messages different display boxes can receive. So if I go to the Help menu, and select Scripting Index, I could change from All Categories to Display Boxes, and scroll down to find FrameBox and see the messages that can be sent to that. I'm going to close the scripting index. The other thing we wanted to do is, on the AxisBox, we want to add a reference line. And again, I would use-- if I wasn't familiar with the-- if I wasn't familiar with the display tree structure for Graph Builder, I would look at that Tree Structure window. in some platforms is the vertical axis. In some platforms, it's the horizontal. In this case, it's the horizontal axis. I send the message to add the reference line. And the arguments here are what value do you want the reference line to be at? I want it at What style of line? I want solid. The color? I'll get black. The fourth argument is a label on the axis. And so by just having an empty character string, we're saying we don't want a label. In fact, I could delete that as long as I have this comma to tell JMP that this is the fifth argument, and not the fourth argument. If I didn't have this comma, then JMP would label the axis with a But because I put the comma there, JMP understands this is the line width, not the label. So I'm going to run line And that draws my reference line. And then, the very last piece of this script is to send "Save Journal" to the display box stored in nw, and call it Custom CV Report.jrn. Now, your script might end here by producing this report with the live Graph Builder window and the red triangle menu for the user to interact with. And in fact, I'll go ahead and select one decimal place this time. In some cases, you may also want to save that report as a journal. And you'll lose that red triangle menu when you do that. And your Graph Builder will no longer be a live report. But the last option here shows how you can save a custom report as a journal with the message "Save Journal." So in this script, we launched the analysis layer. We retrieved the report layer object, and then got the elements of that report layer that we needed either as copies or as matrices for manipulations. We created a separate data table for the platform that we wanted to use, and then created the custom report using New Window, In this case with tabs, and horizontal list boxes, and outline boxes as our display boxes, in addition to the string column box stored in Levels and the various number column boxes. And then, we saw how to send messages to components of that custom report.