Advanced Use of Properties and Scripts in TIBCO Spotfire
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
18,357
On Slideshare
18,357
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
236
Comments
0
Likes
4

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Advanced Use of Properties and Scripts in TIBCO Spotfire
    • C.R.E.A.Te Community of Research Excellence & Advanced Technology
    Janssen Research & Development Herwig Van Marck
  • 2. Overview
    • Examples of the use of properties
      • Trellis Simulation
      • Using $map and $csearch
    • Examples of the use of scripts
      • Using comma separated tag columns
      • Expand marking
      • Dynamic list box content
  • 3. Trellis Simulation Team, Player Name A t B a t s B i l l M u e l l e r E d g a r R e n t e r i a J o h n n y D a m o n M a n n y R a m i r e z A r a m i s R a m i r e z D e r r e k L e e J e r r y H a i r s t o n M i c h a e l B a r r e t t T o d d H o l l a n d s w … A . J . P i e r z y n s k i C a r l E v e r e t t J o e C r e d e P a u l K o n e r k o T a d a h i t o I g u c h i B o s t o n C h i C u b s C h i S o x B i l l M u e l l e r E d g a r R e n t e r i a J o h n n y D a m o n M a n n y R a m i r e z A r a m i s R a m i r e z D e r r e k L e e J e r r y H a i r s t o n M i c h a e l B a r r e t t T o d d H o l l a n d s w … A . J . P i e r z y n s k i C a r l E v e r e t t J o e C r e d e P a u l K o n e r k o T a d a h i t o I g u c h i B o s t o n C h i C u b s C h i S o x B i l l M u e l l e r E d g a r R e n t e r i a J o h n n y D a m o n M a n n y R a m i r e z A r a m i s R a m i r e z D e r r e k L e e J e r r y H a i r s t o n M i c h a e l B a r r e t t T o d d H o l l a n d s w … A . J . P i e r z y n s k i C a r l E v e r e t t J o e C r e d e P a u l K o n e r k o T a d a h i t o I g u c h i B o s t o n C h i C u b s C h i S o x 600 550 500 450 400 350 300 250 200 Boston Chi Cubs Chi Sox Color by Team Boston Chi Cubs Chi Sox
  • 4. Trellis Simulation B i l l M u e l l e r D a v i d O r t i z E d g a r R e n t e r i a J a s o n V a r i t e k J o h n n y D a m o n K e v i n M i l l a r M a n n y R a m i r e z T r o t N i x o n A r a m i s R a m i r e z C o r e y P a t t e r s o n D e r r e k L e e J e r o m y B u r n i t z J e r r y H a i r s t o n J o s e M a c i a s M i c h a e l B a r r e t t N e i f i P e r e z T o d d H o l l a n d s w o r t h T o d d W a l k e r A . J . P i e r z y n s k i A a r o n R o w a n d C a r l E v e r e t t J e r m a i n e D y e J o e C r e d e J u a n U r i b e P a u l K o n e r k o S c o t t P o d s e d n i k T a d a h i t o I g u c h i B o s t o n C h i C u b s C h i S o x 600 550 500 450 400 350 300 250 200 Number of Teams/page  3 Select page 2 Legend Team Team Boston Chi Cubs Chi Sox   per Player per Team At Bats
  • 5. Trellis Simulation
    • Create document properties
      • “ teamsPrPageProp ” (integer)
      • “ selectedPage ” (integer)
      • “ valueProp ” (column name)
    • Create ‘Calculated column’ “ Page ”:
      • Integer((DenseRank([Team])-1)/ ${teamsPrPageProp} +1)
    • Custom expression on X-axis:
      • <if( [Page] = ${selectedPage} ,[Team],&quot;&quot;) as [Team] NEST if( [Page] = ${selectedPage} ,[Player Name],&quot;&quot;) as [Player Name]>
    • Custom expression on Yaxis:
      • if( [Page] = ${selectedPage} , $esc(${valueProp}),null) as $esc(${valueProp})
    Number of Teams/page  3 Select page 2   per Player per Team At Bats
  • 6. Using $map and $csearch *run*
  • 7. Using $map and $csearch
    • Create ‘Input Field’ in text area
    • Create associated document property “ SearchProp ”
    Text Area Y - Axis property search: *run*
  • 8. Using $map and $csearch
    • Use custom expression on Y-axis
      • $map(&quot; sum( $esc( $csearch([Baseball],&quot; ${SearchProp} &quot;) ) ) as $esc( $csearch([Baseball],&quot; ${SearchProp} &quot;) ) &quot;,&quot;, &quot;)
      • Search columns:
        • $csearch([Baseball],&quot; ${SearchProp} &quot;)
      • Escape columns:
        • $esc(…)
      • Summarization + renaming of the axis label:
        • sum(…) as …
      • Handle multiple columns:
        • $map(&quot;…&quot;,&quot;, &quot;)
  • 9. Comma separated tags column
    • Data from a literature search (on next generation sequencing)
    • Comma separated tags column (“Tags”)
    Tags De novo Assembly Genome Annotation, Derivative technology, Multiple Analysis Steps Alignment Alignment Genome Annotation QC Analysis …
  • 10. Comma separated tags column Detail on single paper 19 columns
  • 11. Comma separated tags column
    • Text area for parameters and scripts
      • Drop-down list for column selection
        • Document property “ TagColumn ”
      • Create document property “ TagsList ”
        • Via temporary “List box (multiple select)”
        • Fill with values with Iron Python script
    Tag processing     Tags Get tag values Mark selected row
  • 12. Comma separated tags column
    • GetTags script:
    from System import Array from Spotfire.Dxp.Data import IndexSet from Spotfire.Dxp.Data import DataValueCursor rowCount = Document.ActiveDataTableReference.RowCount rowsToInclude = IndexSet(rowCount,True) #Create a cursor to the Column we wish to get the values from cursor1 = DataValueCursor.CreateFormatted(Document.ActiveDataTableReference.Columns[ColumnName]) keys=dict() #Loop through all rows, retrieve value for specific column, and add value into array for row in Document.ActiveDataTableReference.GetRows(rowsToInclude,cursor1): value1 = cursor1.CurrentValue for tag in value1.split(', '): keys[tag]=1 strArray = Array.CreateInstance(str,len(keys)) idx=0 for key in keys: strArray[idx] = key idx=idx+1 #Set property to array created above Document.Properties.Item[ListProperty]=strArray Get unique tag values Put in “Tagslist” property     Tags Get tag values Mark selected row Script parameters Name Type Value ColumnName String “ ${TagColumn}” ListProperty String TagsList
  • 13. Comma separated tags column
    • Custom Expression on Y-axis:
      • $map(&quot; Integer(Sum( if(find(&quot;&quot;, ${TagsList}, &quot;&quot;,&quot;&quot;, &quot;&quot;&[Tags]&&quot;&quot;, &quot;&quot;)>0,1,null) )) as $esc(${TagsList}) &quot;, &quot;,&quot;)
      • Search for for tag (caveat: quoting the quotes )
        • if(find(&quot;&quot;, ${TagsList}, &quot;&quot;,&quot;&quot;, &quot;&quot;&[Tags]&&quot;&quot;, &quot;&quot;)>0,1,null)
      • Summarization + renaming of the axis label
        • Integer(Sum(…)) as $esc(${TagsList})
      • Handle multiple tags
        • $map(&quot;…&quot;, &quot;,&quot;)
    D a t a v o l u m e s A l i g n m e n t / A s s e m b l y V i e w e r s M u l t i p l e A n a l y s i s S t e p s G e n o m e A n n o t a t i o n S N P / D I P D e t e c t i o n D e r i v a t i v e t e c h n o l o g y D e n o v o A s s e m b l y D a t a s t o r a g e A l i g n m e n t T a r g e t e d R e s e q u e n c i n g D a t a i n t e g r a t i o n D a t a r e p r e s e n t a t i o n E r r o r C o r r e c t i o n Q C A n a l y s i s R a w D a t a A n a l y s i s S t r u c t u r a l V a r i a n t s D e t e c t i o n C o p y N u m b e r V a r i a t i o n G e n o t y p e C a l l i n g ( E m p t y ) 14 12 10 8 6 4 2 0 14 12 12 11 9 9 8 8 7 6 6 4 4 3 2 2 1 1 0
  • 14. Comma separated tags column
    • Selection Problem
      • because all data is derived from all records
    • Solution:
      • “ horizontal bar chart” using cross table
        • Repeat(&quot;&quot;|&quot;&quot;,Integer(Sum(…))) …
      • Use column sorting as selector and Iron Python script
    Tag count Data volumes Alignment/Assembly Viewers Multiple Analysis Steps Genome Annotation SNP/DIP Detection Derivative technology De novo Assembly Data storage Alignment Targeted Resequencing Data integration Data representation Error Correction QC Analysis Raw Data Analysis Structural Variants Detection Copy Number Variation Genotype Calling ||||||||||||||(14) ||||||||||||(12) ||||||||||||(12) |||||||||||(11) |||||||||(9) |||||||||(9) ||||||||(8) ||||||||(8) |||||||(7) ||||||(6) ||||||(6) ||||(4) ||||(4) |||(3) ||(2) ||(2) |(1) |(1)     Tags Get tag values Mark selected row
  • 15. Comma separated tags column
    • MarkSelectedRow script:
    from Spotfire.Dxp.Application.Visuals import VisualContent from Spotfire.Dxp.Data import IndexSet from Spotfire.Dxp.Data import RowSelection from Spotfire.Dxp.Data import DataValueCursor vc = vis.As[VisualContent]() dataTable=vc.Data.DataTableReference marking=vc.Data.MarkingReference selectRows = IndexSet(vc.Data.DataTableReference.RowCount, False); if (vc.SortColumnsCategory): selectedTag=vc.SortColumnsCategory.ToString() rowCount = dataTable.RowCount rowsToInclude = IndexSet(rowCount,True) #Create a cursor to the Column we wish to get the values from cursor1 = DataValueCursor.CreateFormatted(dataTable.Columns[TagsColumn]) #Loop through all rows and check for tag idx=0 for row in dataTable.GetRows(rowsToInclude,cursor1): value1 = cursor1.CurrentValue found=False for tag in value1.split(', '): if (tag==selectedTag): found=True break if found: selectRows[idx]=True idx=idx+1 marking.SetSelection(RowSelection(selectRows), dataTable) Get “selected” tag Set marking Find records with “selected” tag Script parameters Name Type Value vis Visualization Tagging>HBar TagsColumn String “ ${TagColumn}”
  • 16. Expand marking
  • 17. Expand marking
  • 18. Expand Marking
    • Expand marking to all other records with the same value for a chosen column (e.g. Position)
    • Solution:
      • Add a second data table containing the unique values
      • Define relation between the 2 tables on the chosen column
      • Marking something in data table 1 changes the marking in data table 2 due to the relation between the data tables
      • Re-applying the marking in data table 2 changes the marking in data table 1 (effectively expanding it)
      • Iron Python script to re-apply a marking
  • 19. Expand Marking
    • Script to re-apply a marking:
    from Spotfire.Dxp.Application.Visuals import VisualContent vc = vis.As[VisualContent]() dataTable=vc.Data.DataTableReference marking=vc.Data.MarkingReference marking.SetSelection(marking.GetSelection(dataTable),dataTable) Get data table and marking from visualization Re-apply marking Script parameters Name Type Value vis Visualization Page>Table
  • 20. Dynamic list box content
    • Multi select list box in a text area
    • How do you dynamicaly change the contents?
      • Subset of unique values from a column, selected by marking
    Select symbols for list Approve … A1BG A1CF A2LD1 A2M A2ML1 A4GALT A4GNT AAAS AACS AADAC AADACL2 AADACL3 AADACL4 AADAT AAGAB AAK1   Load marked symbols A2LD1 A2M A4GALT AAAS AADAC AADACL3 AADACL4 AADAT AAK1 Cross Table S e l e c t e d G e n e S y m b o l s Selected Gene Symbols Chromosome AAAS AADACL3 (Empty) 12q13 1p36.21
  • 21. Dynamic list box content
    • Define a tag column (e.g. ‘ SelectedGenes ’)
      • Create a tag ‘ Selected ’
    • Create a calculated column (e.g. ‘ Selected Gene Symbols ’)
      • if( [SelectedGenes] =&quot; Selected &quot;,[Approved Symbol],null)
    • Fill list box with unique values from [Selected Gene Symbols]
    • Use Iron Python script to modify tag column
  • 22. Dynamic list box content
    • Script to set ‘tagValue’ in ‘tagColumn’ for marked records
    from Spotfire.Dxp.Data import DataManager,TagsColumn,IndexSet,RowSelection selection=Application.GetService[DataManager]().Markings[markingName].GetSelection(dataTable) col=dataTable.Columns[tagColumn].As[TagsColumn]() # remove tag in tagColumn for all rows in dataTable idx=IndexSet(selection.TotalRowCount,True) col.Tag(&quot;&quot;,RowSelection(idx)) # tag marked rows in tagColumn with tagValue col.Tag(tagValue,selection) Remove all tags in ‘tagColumn’ Set ‘tagValue’ tag in ‘tagColumn’ for records marked in ‘markingName’ Script parameters Name Type Value dataTable DataTable Data Table markingName String Select Marking tagColumn String SelectedGenes tagValue String Selected