text: user2621: This question was also asked on github
  I'm trying to run the function HeatmapAnnotation (a function in the ComplexHeatmap package). When I run it, I get the error "Error in col2rgb(colors, alpha = TRUE) : invalid RGB specification"
  col2rgb() is not among the libraries I've loaded and it doesn't seem to be a method contained in HeatmapAnnotation.
  Here's the code block for the section:
  df <- data.frame(labid= combmetadata$Sample_Name,
               Diagnosis= combmetadata$Diagnosis,
               Tissue = combmetadata$Tissue,
               Tumor.Normal = combmetadata$T.N,
               study = combmetadata$batch)
  
   labid <- colnames(bValsselect)
   df <- left_join(as.data.frame(labid),df,by="labid")
   df <- df[,c(2,4,5)]
   df$study[df$study == "1" | df$study == "2"] <- "cgid"
  
   df$Diagnosis <- factor(df$Diagnosis, levels = c("Uterine endometrial","Ovarian endometrioid",
                                              "Ovarian mucinous",
                                              "Colorectal mucinous",
                                              "Pancreas mucinous",
                                              "Stomach mucinous"))
  
   ha_column = HeatmapAnnotation(df = df, 
                            col = list(Diagnosis = c("Uterine endometrial" = "#DDCC77F",
                                            "Ovarian endometrioid" = "#0F7554",
                                            "Ovarian mucinous" = "#44AA99",
                                            "Colorectal mucinous" = "#882255",
                                            "Pancreas mucinous" = "#AA4499",
                                            "Stomach mucinous" = "#D695D0"),
                              Tumor.Normal = c("N" = "grey",
                                               "T" = "black"),
                              study = c("cgid" = "#332288",
                                        "tcga" = "#BD9AF7")))
  
  hegt <- Heatmap(bValsselect,
              column_split=4,
              name = "Beta Value",
              col = colorRamp2(c(0,0.25,0.5),c("#00FFCC","#FFFFFF","#0099FF")),
              show_row_names = FALSE, 
              top_annotation = ha_column,
              show_row_dend = F)
  
  The code runs fine up until it reaches the end of the HeatmapAnnotation() call
  I've tried to load col2rgb() and override the alpha setting. Can anyone give me a clue about what's happening and any suggestions on how to correct the problem?  I'm running R 4.2. Thanks
  
  user2108: Looking at the documentation, it seems that HeatmapAnnotation expects a vector, whereas you are giving it a list. It is not clear on what acceptable color types are. It might even work with a list, but I'd suggest playing around with what you are supplying as your col parameter.
  Note that HeatmapAnnotation has to do color mapping of some kind, the code is a little dense, but it does look like it calls out to SingleAnnotation, which in turn runs ColorRamp2, which does use col2rgb.
  It also looks like col2rgb is called in ColorRamp2, which you use in the Heatmap call. How sure are you that your script isn't making it that far? It would help to see error output, possibly.
  That said, when I take your isolated ColorRamp2 and run it, it goes ok. Possibly pull out the ColorRamp2 call and run it yourself in your environment to make sure nothing weird is happening.
  Try moving the assignment of the colors outside the Heatmap call, occasionally supplying function calls as parameters like that causes issues.
  
original_text: 2621: <p><em>This question was also asked on <a href="https://github.com/jokergoo/ComplexHeatmap/issues/913" rel="nofollow noreferrer">github</a></em></p>
  <p>I'm trying to run the function HeatmapAnnotation (a function in the ComplexHeatmap package). When I run it, I get the error &quot;Error in col2rgb(colors, alpha = TRUE) : invalid RGB specification&quot;</p>
  <p>col2rgb() is not among the libraries I've loaded and it doesn't seem to be a method contained in HeatmapAnnotation.</p>
  <p>Here's the code block for the section:</p>
  <pre><code>df &lt;- data.frame(labid= combmetadata<span class="math-container">$Sample_Name,
               Diagnosis= combmetadata$</span>Diagnosis,
               Tissue = combmetadata<span class="math-container">$Tissue,
               Tumor.Normal = combmetadata$</span>T.N,
               study = combmetadata$batch)
  
   labid &lt;- colnames(bValsselect)
   df &lt;- left_join(as.data.frame(labid),df,by=&quot;labid&quot;)
   df &lt;- df[,c(2,4,5)]
   df<span class="math-container">$study[df$</span>study == &quot;1&quot; | df$study == &quot;2&quot;] &lt;- &quot;cgid&quot;
  
   df<span class="math-container">$Diagnosis &lt;- factor(df$</span>Diagnosis, levels = c(&quot;Uterine endometrial&quot;,&quot;Ovarian endometrioid&quot;,
                                              &quot;Ovarian mucinous&quot;,
                                              &quot;Colorectal mucinous&quot;,
                                              &quot;Pancreas mucinous&quot;,
                                              &quot;Stomach mucinous&quot;))
  
   ha_column = HeatmapAnnotation(df = df, 
                            col = list(Diagnosis = c(&quot;Uterine endometrial&quot; = &quot;#DDCC77F&quot;,
                                            &quot;Ovarian endometrioid&quot; = &quot;#0F7554&quot;,
                                            &quot;Ovarian mucinous&quot; = &quot;#44AA99&quot;,
                                            &quot;Colorectal mucinous&quot; = &quot;#882255&quot;,
                                            &quot;Pancreas mucinous&quot; = &quot;#AA4499&quot;,
                                            &quot;Stomach mucinous&quot; = &quot;#D695D0&quot;),
                              Tumor.Normal = c(&quot;N&quot; = &quot;grey&quot;,
                                               &quot;T&quot; = &quot;black&quot;),
                              study = c(&quot;cgid&quot; = &quot;#332288&quot;,
                                        &quot;tcga&quot; = &quot;#BD9AF7&quot;)))
  
  hegt &lt;- Heatmap(bValsselect,
              column_split=4,
              name = &quot;Beta Value&quot;,
              col = colorRamp2(c(0,0.25,0.5),c(&quot;#00FFCC&quot;,&quot;#FFFFFF&quot;,&quot;#0099FF&quot;)),
              show_row_names = FALSE, 
              top_annotation = ha_column,
              show_row_dend = F)
  </code></pre>
  <p>The code runs fine up until it reaches the end of the HeatmapAnnotation() call</p>
  <p>I've tried to load col2rgb() and override the alpha setting. Can anyone give me a clue about what's happening and any suggestions on how to correct the problem?  I'm running R 4.2. Thanks</p>
   2108: <p>Looking at the <a href="https://www.rdocumentation.org/packages/ComplexHeatmap/versions/1.10.2/topics/SingleAnnotation" rel="nofollow noreferrer">documentation</a>, it seems that <code>HeatmapAnnotation</code> expects a vector, whereas you are giving it a list. It is not clear on what acceptable color types are. It might even work with a list, but I'd suggest playing around with what you are supplying as your <code>col</code> parameter.</p>
  <p>Note that <code>HeatmapAnnotation</code> has to do color mapping of some kind, the <a href="https://github.com/jokergoo/ComplexHeatmap/blob/master/R/HeatmapAnnotation-class.R" rel="nofollow noreferrer">code</a> is a little dense, but it does look like it calls out to <code>SingleAnnotation</code>, <a href="https://github.com/jokergoo/ComplexHeatmap/blob/master/R/SingleAnnotation-class.R#L495-L507" rel="nofollow noreferrer">which in turn runs <code>ColorRamp2</code></a>, which does use <code>col2rgb</code>.</p>
  <p>It also looks like <code>col2rgb</code> is called in <code>ColorRamp2</code>, which you use in the <code>Heatmap</code> call. How sure are you that your script isn't making it that far? It would help to see error output, possibly.</p>
  <p>That said, when I take your isolated <code>ColorRamp2</code> and run it, it goes ok. Possibly pull out the <code>ColorRamp2</code> call and run it yourself in your environment to make sure nothing weird is happening.</p>
  <p>Try moving the assignment of the colors outside the <code>Heatmap</code> call, occasionally supplying function calls as parameters like that causes issues.</p>
  