<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to modify a correlation matrix heatmap in PROC IML in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-modify-a-correlation-matrix-heatmap-in-PROC-IML/m-p/788863#M5746</link>
    <description>&lt;P&gt;It looks like you found &lt;A href="https://blogs.sas.com/content/iml/2018/05/02/reorder-variables-correlation-heat-map.html" target="_self"&gt;the blog post the describes how to reorder the variables so that highly correlated variables are next to each other&lt;/A&gt;.&amp;nbsp;Use that article to do (2).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For (1), use the COLORRAMP= option and specify a valid color ramp. The &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_013/imlug/imlug_langref_sect188.htm" target="_self"&gt;documentation for the HEATMAPCONT subroutine&lt;/A&gt; describes four ways to define color ramps. For example, the blog post uses&lt;/P&gt;
&lt;PRE&gt;colors = palette("BrBg", 7);&lt;/PRE&gt;
&lt;P&gt;As explained in the documentation of the HEATMAPCONT subroutine, you can often accomplish (3) by defining short labels and using the XVALUES= and YVALUES= keywords to specify the labels. FOr example, here is a modification of the example from the blog post for which I use custom labels:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
/* create correlation matric for variables in alphabetical order */
varNames = {'Cylinders' 'EngineSize' 'Horsepower' 'Invoice' 'Length' 
            'MPG_City' 'MPG_Highway' 'MSRP' 'Weight' 'Wheelbase'};
use Sashelp.Cars;  read all var varNames into Y;  close;
corr = corr(Y);
colors = palette("BrBg", 7);

/* define custom labels (keep them short) */
labels = {'Cyl-10' 'EngSize-02' 'HP-001A' 'Invoice' 'Length' 
            'MPG (City)' 'MPG (Highway)' 'MSRP' 'Weight' 'Wheelbase'};

call HeatmapCont(corr) xvalues=varNames yvalues=varNames 
            colorramp=colors range={-1.01 1.01} 
            xvalues=labels yvalues=labels
            title="Correlation Matrix: Variables in Alphabetical Order";


&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 07 Jan 2022 14:21:31 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-01-07T14:21:31Z</dc:date>
    <item>
      <title>How to modify a correlation matrix heatmap in PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-modify-a-correlation-matrix-heatmap-in-PROC-IML/m-p/788795#M5744</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am doing a study looking at correlations between multiple cytokines. I found code to let me graph a heatmap of the correlation matrix, but I am having trouble making modifications to the heatmap.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.) Specifically, I would like to be able to change the color, i.e. instead of white = -1 and dark blue = +1, I was hoping to use a different color for &amp;lt;1 values to make the correlation values more obvious.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.) In addition, I was hoping to reorder the cytokines so that the strongest and weakest correlations are next to each other to make the data more interpretable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3.) I also in a perfect world would be able to re-label the cytokine names so that show up prettier (e.g. with hyphens instead of underscores, etc).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code below. The last paragraph of code is what I was trying to use to modify the order of the cytokines (labeled/* load the module for single-link clustering */). I am also attaching images of what my heatmaps currently look like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any guidance would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;/*HEAT MAP CORRELATION MATRIX FOR ALL SAMPLES*/&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;TITLE&lt;/SPAN&gt; "Correlation Matrix for All Samples"&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;iml&lt;/STRONG&gt;&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;/* create correlation matric for variables in alphabetical order */&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;varNames = {&lt;/SPAN&gt;'IL_28A''IL_6''IL_8''IL_7''IFN_Beta''IL_10''CCL2''IL_1b''IFN_g''CCL3''CCL22''CCL4''IL_4'&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;/*'IL_17A' 'IL_2'*/&lt;/SPAN&gt; 'CXCL9' 'IL_5' 'TNFRI' 'IL12p70' 'CCL17' 'TNFa' 'IL_28B' 'CXCL10' &lt;SPAN class=""&gt;/*'IL_23'*/&lt;/SPAN&gt;&lt;SPAN class=""&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;/*Sample_cat = sample_cat;&lt;/P&gt;&lt;P class=""&gt;Dz_severity_binary2 = Dz_severity_binary2;*/&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;use&lt;/SPAN&gt; Gawlib.cytokine_80121 where (Dz_severity_binary2 &amp;gt;=&lt;SPAN class=""&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;) ; &lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;read&lt;/SPAN&gt; all &lt;SPAN class=""&gt;var&lt;/SPAN&gt; varNames &lt;SPAN class=""&gt;into&lt;/SPAN&gt; Y where (sample_cat&amp;gt;=&lt;SPAN class=""&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;) ; &lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;read&lt;/SPAN&gt; all &lt;SPAN class=""&gt;var&lt;/SPAN&gt; varNames &lt;SPAN class=""&gt;into&lt;/SPAN&gt; Y where (sample_cat&amp;gt;=&lt;SPAN class=""&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;) ; &lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;close&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;corr = corr(Y, &lt;SPAN class=""&gt;"Spearman"&lt;/SPAN&gt;);&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;call&lt;/SPAN&gt; HeatmapCont(corr) xvalues=varNames yvalues=varNames&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;colorramp=colors range={-&lt;SPAN class=""&gt;&lt;STRONG&gt;1.01&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;STRONG&gt;1.01&lt;/STRONG&gt;&lt;/SPAN&gt;}&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;title=&lt;/SPAN&gt;"Correlation Matrix: Cytokine levels for all samples"&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;/* load the module for single-link clustering */&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;load&lt;/SPAN&gt; &lt;SPAN class=""&gt;module&lt;/SPAN&gt;=(SingleLinkCluster);&lt;/P&gt;&lt;P class=""&gt;permutation = SingleLinkCluster( corr );&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class=""&gt;/* permutation of 1:p */&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;V = varNames[permutation];&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class=""&gt;/* new order for variables */&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;R = corr[permutation, permutation]; &lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class=""&gt;/* new order for matrix */&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;call&lt;/SPAN&gt; HeatmapCont(R) xvalues=V yvalues=V&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;colorramp=colors range={-&lt;SPAN class=""&gt;&lt;STRONG&gt;1.01&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;STRONG&gt;1.01&lt;/STRONG&gt;&lt;/SPAN&gt;}&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;title=&lt;/SPAN&gt;"Correlation: Variables in Clustered Order"&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 04:46:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-modify-a-correlation-matrix-heatmap-in-PROC-IML/m-p/788795#M5744</guid>
      <dc:creator>Kels123</dc:creator>
      <dc:date>2022-01-07T04:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify a correlation matrix heatmap in PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-modify-a-correlation-matrix-heatmap-in-PROC-IML/m-p/788836#M5745</link>
      <description>&lt;P&gt;Why not post it at IML forum and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp; is there .&lt;/P&gt;
&lt;P&gt;and also could check&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;call&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;HeatmapDist()&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 12:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-modify-a-correlation-matrix-heatmap-in-PROC-IML/m-p/788836#M5745</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-07T12:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify a correlation matrix heatmap in PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-modify-a-correlation-matrix-heatmap-in-PROC-IML/m-p/788863#M5746</link>
      <description>&lt;P&gt;It looks like you found &lt;A href="https://blogs.sas.com/content/iml/2018/05/02/reorder-variables-correlation-heat-map.html" target="_self"&gt;the blog post the describes how to reorder the variables so that highly correlated variables are next to each other&lt;/A&gt;.&amp;nbsp;Use that article to do (2).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For (1), use the COLORRAMP= option and specify a valid color ramp. The &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_013/imlug/imlug_langref_sect188.htm" target="_self"&gt;documentation for the HEATMAPCONT subroutine&lt;/A&gt; describes four ways to define color ramps. For example, the blog post uses&lt;/P&gt;
&lt;PRE&gt;colors = palette("BrBg", 7);&lt;/PRE&gt;
&lt;P&gt;As explained in the documentation of the HEATMAPCONT subroutine, you can often accomplish (3) by defining short labels and using the XVALUES= and YVALUES= keywords to specify the labels. FOr example, here is a modification of the example from the blog post for which I use custom labels:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
/* create correlation matric for variables in alphabetical order */
varNames = {'Cylinders' 'EngineSize' 'Horsepower' 'Invoice' 'Length' 
            'MPG_City' 'MPG_Highway' 'MSRP' 'Weight' 'Wheelbase'};
use Sashelp.Cars;  read all var varNames into Y;  close;
corr = corr(Y);
colors = palette("BrBg", 7);

/* define custom labels (keep them short) */
labels = {'Cyl-10' 'EngSize-02' 'HP-001A' 'Invoice' 'Length' 
            'MPG (City)' 'MPG (Highway)' 'MSRP' 'Weight' 'Wheelbase'};

call HeatmapCont(corr) xvalues=varNames yvalues=varNames 
            colorramp=colors range={-1.01 1.01} 
            xvalues=labels yvalues=labels
            title="Correlation Matrix: Variables in Alphabetical Order";


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Jan 2022 14:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-modify-a-correlation-matrix-heatmap-in-PROC-IML/m-p/788863#M5746</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-01-07T14:21:31Z</dc:date>
    </item>
  </channel>
</rss>

