Query view does not show R script view?

Study Forum (Inactive)
Query view does not show R script view? wonjong.moon  2008-02-28 12:04
Status: Closed
 
I followed the path below to go to the R script of the query 'JC' that I joined all tables in labkey
Manage Reports and Views -> new grid view -> Modify Dataset List (Advanced) -> 'JC' run -> R script veiw

I placed query tab in front of the project page, but it does not show the R script view I made.


I attached two image files;
labkeyRq.JPG shows the R script view

labkeyRq1.JPG does not show the R script view.

Can I place the query 'JC' with the R script view?

I know I can directly place R script view using 'manange report', but I need to show all data to users first and then let them select one ID and then generate R report for that specific ID.

Thanks.
 
 
marki responded:  2008-02-28 13:56
Hi Wonjong. It looks like the web part doesn't include the custom view. We have an issue for adding a way to put a just an R view on a page, but it sounds like what you want to do is just have a user pick a participant & show the R-view on that subset of data.

If that's what you want to do, I have a couple of solutions that should work well. Just let me know.
 
wonjong.moon responded:  2008-02-28 14:42
Yes,exactly. I want to show R-view on the subset of data.
Thank you.
 
marki responded:  2008-02-29 13:35
OK, so what you want is a way to show the R-report for a pre-filtered dataset. This requires two things

1) A way to pick the participant you want to view
2) A way to generate the custom URL that shows the filtered R report

Let's take this backward. The URL for your R report (when you get to it), looks something like this:

https://xxx.sbri.org/labkey/reports/MyStudy/runRReport.view?reportId=221&query.queryName=MyQuery&schemaName=study

Note the parameters reportId, query.queryName and schemaName. When you filter the data to a particular participant it adds a filter of the form query.ParticipantId~eq=700010019 on the end like this

https://xxx.sbri.org/labkey/reports/MyStudy/runRReport.view?reportId=221&query.queryName=MyQuery&schemaName=study&query.ParticipantId~eq=700010019

So what we want is a form where users can enter a participantID and create the URL. You can create an HTML wiki that does that:

<form method=GET action='/labkey/reports/MyStudy/runRReport.view'>
<input type=hidden name="reportId" value="221">
<input type=hidden name="query.queryName" value="MyQuery">
<input type=hidden name="schemaName" value="Study">
<table>
<tr>
<td>Show clinical and specimen summary for participant </td>
<td>
<input type="text" name="query.participantId~eq"/>
</td>
<td><input align=bottom type=image src='/labkey/Go.button'></td>
</tr>
</table>
</form>

Things to note:
* The parameters are converted to hidden parameters in the form. They'll get attached to the form when the go button is clicked
* The participantId~eq parameter will get filled in with the participantId typed in the text box

It would also be cool to add autocomplete to that input box based on all available participant id's. If you are an site administrator you can create script in your HTML wikis. Turns out there's a bit of script you can put in your wiki that allows just this autocomplete. Here's what you'd do

<script>LABKEY.requiresScript('completion.js')</script>
<form method=GET action='/labkey/reports/MyStudy/runRReport.view'>
<input type=hidden name=reportId value="221">
<input type=hidden name="query.queryName" value="MyQuery">
<input type=hidden name="schemaName" value="Study">
<table>
<tr>
<td>Show clinical and specimen summary for participant </td>
<td>
<input type="text" onkeyup="return handleChange(this, event, '/labkey/Study-Samples/MyStudy/autoComplete.view?type=ParticpantId&prefix=');" value="" autocomplete="off" onblur="hideCompletionDiv();" onkeydown="return ctrlKeyCheck(event);" name="query.participantId~eq"/>
</td>
<td><input align=bottom type=image src='/labkey/Go.button'></td>
</tr>
</table>
</form>

There are two changes here
* The script to include completion.js, which provides a handleChange function
* The handleChange javascript funtion takes a path to the folder with all your participants. Replace MyStudy with the path to your study folder on your server
 
wonjong.moon responded:  2008-03-02 14:52
This wiki html worked well. I can type one patient id into the form and get R report. It's great!
-----------------------------------------------------------------------
<form method=GET action='/reports/Morogoro_RNA/runRReport.view'>
<input type=hidden name="reportId" value="37">
<input type=hidden name="query.queryName" value="JC">
<input type=hidden name="schemaName" value="study">
<table>
<tr>
<td>Show clinical and specimen summary for participant </td>
<td>
<input type="text" name="query.participantId~eq"/>
</td>
<td><input align=bottom type=image src='/labkey/Go.button'></td>
</tr>
</table>
</form>
----------------------------------------------------------------------

As you said, I tried autocompletion, but the html wiki (using completion.js) did not work for me.
----------------------------------------------------------------------
<script>LABKEY.requiresScript('completion.js')</script>
<form method=GET action='reports/Morogoro_RNA/runRReport.view'>
<input type=hidden name=reportId value="37">
<input type=hidden name="query.queryName" value="JC">
<input type=hidden name="schemaName" value="study">
<table>
<tr>
<td>Show clinical and specimen summary for participant </td>
<td>
<input type="text" onkeyup="return handleChange(this, event, '/usr/local/labkey/datasets/morogoro_rna/autoComplete.view?type=ParticpantId&prefix=');" value="" autocomplete="off" onblur="hideCompletionDiv();" onkeydown="return ctrlKeyCheck(event);" name="query.participantId~eq"/>
</td>
<td><input align=bottom type=image src='/labkey/Go.button'></td>
</tr>
</table>
</form>
-------------------------------------------------------------------------------------------

I found 'completion.js' was located under /usr/local/labkey/labkeywebapp
The path to my study folder on sbri server was "usr/local/labkey/datasets/morogoro_rna"
This folder has just lots of *.tsv files.

I tried '/Study-Samples/Morogoro_RNA/autoComplete.view?". It also did not work.

This is the url of my R report view:
http://cpas01.sbri.org/reports/Morogoro_RNA/runRReport.view?reportId=37&query.queryName=JC&schemaName=study&query.viewName=2000956

What would be the correct path?

Thanks.
 
marki responded:  2008-03-02 15:56
The path should be

/[contextPath]/Study-Samples/[path to study folder]/autoComplete.view?type=ParticipantId&prefix=

where [contextPath] is context path of your web app (looks like you don't need one) & [path to study folder] is path to the folder with the data in it. (looks like Morogoro_RNA). The parameters are required.

You can actually test this by typing the full URL (includi http://servername AND the parameters) into a web browser. You will get back an XML document with the ids matching the prefix parameter, if you don't just leave that blank.