Home > OS >  Sectioning in Heat Map using ggplot
Sectioning in Heat Map using ggplot

Time:06-24

I'm trying to plot a heat map, but I want the heat map in four different vertical sections. The first one shall be for "Proneural", then "Neural", then "Classical" and lastly "Mesenchymal"

A sample of my melted data looks something like this:

dput(tdfdarkmagenta1[1:513,])

"TCGA.02.0011.01", "TCGA.02.0014.01", "TCGA.02.0024.01", "TCGA.02.0026.01", 
"TCGA.02.0028.01", "TCGA.02.0046.01", "TCGA.02.0047.01", "TCGA.02.0048.01", 
"TCGA.02.0060.01", "TCGA.02.0069.01", "TCGA.02.0074.01", "TCGA.02.0080.01", 
"TCGA.02.0084.01", "TCGA.02.0087.01", "TCGA.02.0104.01", "TCGA.02.0114.01", 
"TCGA.02.0281.01", "TCGA.02.0321.01", "TCGA.02.0325.01", "TCGA.02.0338.01", 
"TCGA.02.0339.01", "TCGA.02.0432.01", "TCGA.02.0439.01", "TCGA.02.0440.01", 
"TCGA.02.0446.01", "TCGA.06.0128.01", "TCGA.06.0129.01", "TCGA.06.0146.01", 
"TCGA.06.0156.01", "TCGA.06.0166.01", "TCGA.06.0174.01", "TCGA.06.0177.01", 
"TCGA.06.0238.01", "TCGA.06.0241.01", "TCGA.06.0410.01", "TCGA.06.0413.01", 
"TCGA.06.0414.01", "TCGA.06.0646.01", "TCGA.06.0648.01", "TCGA.08.0245.01", 
"TCGA.08.0344.01", "TCGA.08.0347.01", "TCGA.08.0348.01", "TCGA.08.0350.01", 
"TCGA.08.0353.01", "TCGA.08.0359.01", "TCGA.08.0385.01", "TCGA.08.0517.01", 
"TCGA.08.0524.01", "TCGA.12.0616.01", "TCGA.12.0618.01", "TCGA.02.0089.01", 
"TCGA.02.0113.01", "TCGA.02.0115.01", "TCGA.02.0451.01", "TCGA.06.0132.01", 
"TCGA.06.0133.01", "TCGA.06.0138.01", "TCGA.06.0160.01", "TCGA.06.0162.01", 
"TCGA.06.0167.01", "TCGA.06.0171.01", "TCGA.06.0173.01", "TCGA.06.0179.01", 
"TCGA.06.0182.01", "TCGA.06.0185.01", "TCGA.06.0195.01", "TCGA.06.0208.01", 
"TCGA.06.0214.01", "TCGA.06.0219.01", "TCGA.06.0221.01", "TCGA.06.0237.01", 
"TCGA.06.0240.01", "TCGA.08.0349.01", "TCGA.08.0380.01", "TCGA.08.0386.01", 
"TCGA.08.0520.01", "TCGA.02.0007.01", "TCGA.02.0009.01", "TCGA.02.0016.01", 
"TCGA.02.0021.01", "TCGA.02.0023.01", "TCGA.02.0027.01", "TCGA.02.0038.01", 
"TCGA.02.0043.01", "TCGA.02.0070.01", "TCGA.02.0102.01", "TCGA.02.0260.01", 
"TCGA.02.0269.01", "TCGA.02.0285.01", "TCGA.02.0289.01", "TCGA.02.0290.01", 
"TCGA.02.0317.01", "TCGA.02.0333.01", "TCGA.02.0422.01", "TCGA.02.0430.01", 
"TCGA.06.0125.01", "TCGA.06.0126.01", "TCGA.06.0137.01", "TCGA.06.0145.01", 
"TCGA.06.0148.01", "TCGA.06.0187.01", "TCGA.06.0211.01", "TCGA.06.0402.01", 
"TCGA.08.0246.01", "TCGA.08.0354.01", "TCGA.08.0355.01", "TCGA.08.0357.01", 
"TCGA.08.0358.01", "TCGA.08.0375.01", "TCGA.08.0511.01", "TCGA.08.0514.01", 
"TCGA.08.0518.01", "TCGA.08.0529.01", "TCGA.08.0531.01", "TCGA.02.0004.01", 
"TCGA.02.0025.01", "TCGA.02.0033.01", "TCGA.02.0034.01", "TCGA.02.0039.01", 
"TCGA.02.0051.01", "TCGA.02.0054.01", "TCGA.02.0057.01", "TCGA.02.0059.01", 
"TCGA.02.0064.01", "TCGA.02.0075.01", "TCGA.02.0079.01", "TCGA.02.0085.01", 
"TCGA.02.0086.01", "TCGA.02.0099.01", "TCGA.02.0106.01", "TCGA.02.0107.01", 
"TCGA.02.0111.01", "TCGA.02.0326.01", "TCGA.02.0337.01", "TCGA.06.0122.01", 
"TCGA.06.0124.01", "TCGA.06.0130.01", "TCGA.06.0139.01", "TCGA.06.0143.01", 
"TCGA.06.0147.01", "TCGA.06.0149.01", "TCGA.06.0152.01", "TCGA.06.0154.01", 
"TCGA.06.0164.01", "TCGA.06.0175.01", "TCGA.06.0176.01", "TCGA.06.0184.01", 
"TCGA.06.0189.01", "TCGA.06.0190.01", "TCGA.06.0194.01", "TCGA.06.0197.01", 
"TCGA.06.0210.01", "TCGA.06.0397.01", "TCGA.06.0409.01", "TCGA.06.0412.01", 
"TCGA.06.0644.01", "TCGA.06.0645.01", "TCGA.08.0346.01", "TCGA.08.0352.01", 
"TCGA.08.0360.01", "TCGA.08.0390.01", "TCGA.08.0392.01", "TCGA.08.0509.01", 
"TCGA.08.0510.01", "TCGA.08.0512.01", "TCGA.08.0522.01", "TCGA.12.0619.01", 
"TCGA.12.0620.01", "TCGA.02.0003.01", "TCGA.02.0010.01", "TCGA.02.0011.01", 
"TCGA.02.0014.01", "TCGA.02.0024.01", "TCGA.02.0026.01", "TCGA.02.0028.01", 
"TCGA.02.0046.01", "TCGA.02.0047.01", "TCGA.02.0048.01", "TCGA.02.0060.01", 
"TCGA.02.0069.01", "TCGA.02.0074.01", "TCGA.02.0080.01", "TCGA.02.0084.01", 
"TCGA.02.0087.01", "TCGA.02.0104.01", "TCGA.02.0114.01", "TCGA.02.0281.01", 
"TCGA.02.0321.01", "TCGA.02.0325.01", "TCGA.02.0338.01", "TCGA.02.0339.01", 
"TCGA.02.0432.01", "TCGA.02.0439.01", "TCGA.02.0440.01", "TCGA.02.0446.01", 
"TCGA.06.0128.01", "TCGA.06.0129.01", "TCGA.06.0146.01", "TCGA.06.0156.01", 
"TCGA.06.0166.01", "TCGA.06.0174.01", "TCGA.06.0177.01", "TCGA.06.0238.01", 
"TCGA.06.0241.01", "TCGA.06.0410.01", "TCGA.06.0413.01", "TCGA.06.0414.01", 
"TCGA.06.0646.01", "TCGA.06.0648.01", "TCGA.08.0245.01", "TCGA.08.0344.01", 
"TCGA.08.0347.01", "TCGA.08.0348.01", "TCGA.08.0350.01", "TCGA.08.0353.01", 
"TCGA.08.0359.01", "TCGA.08.0385.01", "TCGA.08.0517.01", "TCGA.08.0524.01", 
"TCGA.12.0616.01", "TCGA.12.0618.01", "TCGA.02.0089.01", "TCGA.02.0113.01", 
"TCGA.02.0115.01", "TCGA.02.0451.01", "TCGA.06.0132.01", "TCGA.06.0133.01", 
"TCGA.06.0138.01", "TCGA.06.0160.01", "TCGA.06.0162.01", "TCGA.06.0167.01", 
"TCGA.06.0171.01", "TCGA.06.0173.01", "TCGA.06.0179.01", "TCGA.06.0182.01", 
"TCGA.06.0185.01", "TCGA.06.0195.01", "TCGA.06.0208.01", "TCGA.06.0214.01", 
"TCGA.06.0219.01", "TCGA.06.0221.01", "TCGA.06.0237.01", "TCGA.06.0240.01", 
"TCGA.08.0349.01", "TCGA.08.0380.01", "TCGA.08.0386.01", "TCGA.08.0520.01", 
"TCGA.02.0007.01", "TCGA.02.0009.01", "TCGA.02.0016.01", "TCGA.02.0021.01", 
"TCGA.02.0023.01", "TCGA.02.0027.01", "TCGA.02.0038.01", "TCGA.02.0043.01", 
"TCGA.02.0070.01", "TCGA.02.0102.01", "TCGA.02.0260.01", "TCGA.02.0269.01", 
"TCGA.02.0285.01", "TCGA.02.0289.01", "TCGA.02.0290.01", "TCGA.02.0317.01", 
"TCGA.02.0333.01", "TCGA.02.0422.01", "TCGA.02.0430.01", "TCGA.06.0125.01", 
"TCGA.06.0126.01", "TCGA.06.0137.01", "TCGA.06.0145.01", "TCGA.06.0148.01", 
"TCGA.06.0187.01", "TCGA.06.0211.01", "TCGA.06.0402.01", "TCGA.08.0246.01", 
"TCGA.08.0354.01", "TCGA.08.0355.01", "TCGA.08.0357.01", "TCGA.08.0358.01", 
"TCGA.08.0375.01", "TCGA.08.0511.01", "TCGA.08.0514.01", "TCGA.08.0518.01", 
"TCGA.08.0529.01", "TCGA.08.0531.01", "TCGA.02.0004.01", "TCGA.02.0025.01", 
"TCGA.02.0033.01", "TCGA.02.0034.01", "TCGA.02.0039.01", "TCGA.02.0051.01", 
"TCGA.02.0054.01", "TCGA.02.0057.01", "TCGA.02.0059.01", "TCGA.02.0064.01", 
"TCGA.02.0075.01", "TCGA.02.0079.01", "TCGA.02.0085.01", "TCGA.02.0086.01", 
"TCGA.02.0099.01", "TCGA.02.0106.01", "TCGA.02.0107.01", "TCGA.02.0111.01", 
"TCGA.02.0326.01", "TCGA.02.0337.01", "TCGA.06.0122.01", "TCGA.06.0124.01", 
"TCGA.06.0130.01", "TCGA.06.0139.01", "TCGA.06.0143.01", "TCGA.06.0147.01", 
"TCGA.06.0149.01", "TCGA.06.0152.01", "TCGA.06.0154.01", "TCGA.06.0164.01", 
"TCGA.06.0175.01", "TCGA.06.0176.01", "TCGA.06.0184.01", "TCGA.06.0189.01", 
"TCGA.06.0190.01", "TCGA.06.0194.01", "TCGA.06.0197.01", "TCGA.06.0210.01", 
"TCGA.06.0397.01", "TCGA.06.0409.01", "TCGA.06.0412.01", "TCGA.06.0644.01", 
"TCGA.06.0645.01", "TCGA.08.0346.01", "TCGA.08.0352.01", "TCGA.08.0360.01", 
"TCGA.08.0390.01", "TCGA.08.0392.01", "TCGA.08.0509.01", "TCGA.08.0510.01", 
"TCGA.08.0512.01", "TCGA.08.0522.01", "TCGA.12.0619.01", "TCGA.12.0620.01", 
"TCGA.02.0003.01", "TCGA.02.0010.01", "TCGA.02.0011.01", "TCGA.02.0014.01", 
"TCGA.02.0024.01", "TCGA.02.0026.01", "TCGA.02.0028.01", "TCGA.02.0046.01", 
"TCGA.02.0047.01", "TCGA.02.0048.01", "TCGA.02.0060.01", "TCGA.02.0069.01", 
"TCGA.02.0074.01", "TCGA.02.0080.01", "TCGA.02.0084.01", "TCGA.02.0087.01", 
"TCGA.02.0104.01", "TCGA.02.0114.01", "TCGA.02.0281.01", "TCGA.02.0321.01", 
"TCGA.02.0325.01", "TCGA.02.0338.01", "TCGA.02.0339.01", "TCGA.02.0432.01", 
"TCGA.02.0439.01", "TCGA.02.0440.01", "TCGA.02.0446.01", "TCGA.06.0128.01", 
"TCGA.06.0129.01", "TCGA.06.0146.01", "TCGA.06.0156.01", "TCGA.06.0166.01", 
"TCGA.06.0174.01", "TCGA.06.0177.01", "TCGA.06.0238.01", "TCGA.06.0241.01", 
"TCGA.06.0410.01", "TCGA.06.0413.01", "TCGA.06.0414.01", "TCGA.06.0646.01", 
"TCGA.06.0648.01", "TCGA.08.0245.01", "TCGA.08.0344.01", "TCGA.08.0347.01", 
"TCGA.08.0348.01", "TCGA.08.0350.01", "TCGA.08.0353.01", "TCGA.08.0359.01", 
"TCGA.08.0385.01", "TCGA.08.0517.01", "TCGA.08.0524.01", "TCGA.12.0616.01", 
"TCGA.12.0618.01", "TCGA.02.0089.01", "TCGA.02.0113.01", "TCGA.02.0115.01", 
"TCGA.02.0451.01", "TCGA.06.0132.01", "TCGA.06.0133.01", "TCGA.06.0138.01", 
"TCGA.06.0160.01", "TCGA.06.0162.01", "TCGA.06.0167.01", "TCGA.06.0171.01", 
"TCGA.06.0173.01", "TCGA.06.0179.01", "TCGA.06.0182.01", "TCGA.06.0185.01", 
"TCGA.06.0195.01", "TCGA.06.0208.01", "TCGA.06.0214.01", "TCGA.06.0219.01", 
"TCGA.06.0221.01", "TCGA.06.0237.01", "TCGA.06.0240.01", "TCGA.08.0349.01", 
"TCGA.08.0380.01", "TCGA.08.0386.01", "TCGA.08.0520.01", "TCGA.02.0007.01", 
"TCGA.02.0009.01", "TCGA.02.0016.01", "TCGA.02.0021.01", "TCGA.02.0023.01", 
"TCGA.02.0027.01", "TCGA.02.0038.01", "TCGA.02.0043.01", "TCGA.02.0070.01", 
"TCGA.02.0102.01", "TCGA.02.0260.01", "TCGA.02.0269.01", "TCGA.02.0285.01", 
"TCGA.02.0289.01", "TCGA.02.0290.01", "TCGA.02.0317.01", "TCGA.02.0333.01", 
"TCGA.02.0422.01", "TCGA.02.0430.01", "TCGA.06.0125.01", "TCGA.06.0126.01", 
"TCGA.06.0137.01", "TCGA.06.0145.01", "TCGA.06.0148.01", "TCGA.06.0187.01", 
"TCGA.06.0211.01", "TCGA.06.0402.01", "TCGA.08.0246.01", "TCGA.08.0354.01", 
"TCGA.08.0355.01", "TCGA.08.0357.01", "TCGA.08.0358.01", "TCGA.08.0375.01", 
"TCGA.08.0511.01", "TCGA.08.0514.01", "TCGA.08.0518.01", "TCGA.08.0529.01", 
"TCGA.08.0531.01", "TCGA.02.0004.01", "TCGA.02.0025.01", "TCGA.02.0033.01", 
"TCGA.02.0034.01", "TCGA.02.0039.01", "TCGA.02.0051.01", "TCGA.02.0054.01", 
"TCGA.02.0057.01", "TCGA.02.0059.01", "TCGA.02.0064.01", "TCGA.02.0075.01", 
"TCGA.02.0079.01", "TCGA.02.0085.01", "TCGA.02.0086.01", "TCGA.02.0099.01", 
"TCGA.02.0106.01", "TCGA.02.0107.01", "TCGA.02.0111.01", "TCGA.02.0326.01", 
"TCGA.02.0337.01", "TCGA.06.0122.01", "TCGA.06.0124.01", "TCGA.06.0130.01", 
"TCGA.06.0139.01", "TCGA.06.0143.01", "TCGA.06.0147.01", "TCGA.06.0149.01", 
"TCGA.06.0152.01", "TCGA.06.0154.01", "TCGA.06.0164.01", "TCGA.06.0175.01", 
"TCGA.06.0176.01", "TCGA.06.0184.01", "TCGA.06.0189.01", "TCGA.06.0190.01", 
"TCGA.06.0194.01", "TCGA.06.0197.01", "TCGA.06.0210.01", "TCGA.06.0397.01", 
"TCGA.06.0409.01", "TCGA.06.0412.01", "TCGA.06.0644.01", "TCGA.06.0645.01", 
"TCGA.08.0346.01", "TCGA.08.0352.01", "TCGA.08.0360.01", "TCGA.08.0390.01", 
"TCGA.08.0392.01", "TCGA.08.0509.01", "TCGA.08.0510.01", "TCGA.08.0512.01", 
"TCGA.08.0522.01", "TCGA.12.0619.01", "TCGA.12.0620.01"), X1 = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,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1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", "APOL1", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", "APOL3", 
"APOL3", "APOL3", "APOL3", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6", 
"APOL6", "APOL6", "APOL6", "APOL6", "APOL6", "APOL6"), value = c(6.440614, 
4.885316, 7.338949, 4.041524, 5.639701, 4.593116, 6.855126, 5.749908, 
6.20898, 5.116251, 7.112757, 4.912253, 4.772498, 4.519845, 5.488741, 
4.303682, 4.586598, 4.569936, 4.246869, 4.641265, 4.390102, 4.378184, 
4.447884, 4.487281, 4.564065, 4.538552, 5.27495, 4.729567, 4.739719, 
4.531052, 5.066617, 4.268228, 4.139785, 4.311161, 4.910435, 4.133574, 
4.593644, 4.260337, 4.413737, 5.757798, 4.390029, 4.43645, 4.130543, 
4.594086, 4.308992, 4.351475, 5.879887, 4.851803, 4.509181, 4.200918, 
4.303939, 5.016515, 4.068592, 5.62182, 5.560375, 4.988409, 5.382637, 
5.281838, 5.940274, 4.694935, 4.54053, 4.929523, 4.660801, 4.85447, 
4.498885, 4.675343, 4.973414, 4.509632, 4.534661, 4.418349, 4.45541, 
4.867204, 4.493819, 4.592379, 4.75487, 4.917873, 4.68678, 4.321822, 
4.560718, 5.733584, 6.134006, 4.496007, 5.164066, 5.849103, 7.174979, 
4.322873, 6.196463, 4.817931, 5.303924, 4.321601, 4.543184, 4.643725, 
5.269385, 4.269424, 4.702613, 4.589273, 5.098664, 5.319498, 4.776035, 
4.96718, 4.774047, 6.144412, 4.572852, 5.493287, 4.335304, 4.61989, 
5.427307, 4.779529, 5.290764, 4.455027, 4.449948, 4.621436, 5.796277, 
4.578176, 4.468628, 5.146806, 4.367377, 7.215344, 7.338386, 6.055633, 
6.556766, 5.736861, 6.660201, 5.762708, 8.288329, 4.766171, 6.947097, 
4.640129, 5.218924, 6.313079, 5.130613, 5.333146, 6.623891, 5.795733, 
4.841631, 4.611465, 5.511, 5.696128, 4.695829, 6.082086, 5.420374, 
5.146372, 6.150223, 4.832631, 4.493986, 4.864741, 5.268904, 4.59551, 
5.015461, 4.966011, 4.606592, 4.472855, 4.798533, 4.850255, 4.492938, 
4.714983, 5.322796, 5.584666, 6.370192, 5.26516, 5.162475, 4.649553, 
5.074855, 4.341504, 4.186291, 4.543788, 4.62354, 5.057792, 5.078739, 
4.87731, 4.270871, 7.172938, 4.667727, 7.461402, 4.465189, 4.286208, 
4.956569, 7.604894, 4.99609, 4.925457, 5.781873, 7.255709, 4.956239, 
4.614158, 4.810878, 5.524965, 5.01115, 4.657762, 4.618875, 4.872526, 
5.22322, 5.154723, 4.590917, 5.074051, 4.915427, 5.368831, 4.858911, 
5.883484, 5.471536, 5.048719, 4.980593, 5.112679, 4.495668, 4.521661, 
4.725474, 5.065079, 4.466894, 4.917366, 4.742702, 4.573906, 5.603505, 
4.865531, 4.567824, 4.590841, 5.710199, 5.176365, 4.819056, 5.388128, 
5.552453, 4.77476, 4.822824, 4.364366, 4.901408, 4.62782, 5.692308, 
5.56153, 5.882756, 5.648209, 5.29208, 6.376631, 5.085222, 4.658175, 
5.372237, 4.797157, 4.813454, 4.536243, 5.260207, 5.180298, 4.863735, 
4.962478, 5.285917, 4.841273, 4.777046, 5.1269, 5.102975, 4.875855, 
5.391042, 5.234951, 4.53907, 4.684391, 4.720508, 5.820168, 5.03945, 
4.728882, 5.570849, 8.09192, 4.589245, 4.987684, 5.191648, 4.990668, 
4.713683, 4.96321, 5.072286, 5.228062, 4.826774, 4.956424, 4.894191, 
5.517324, 5.030739, 4.816476, 4.900248, 4.881357, 5.131253, 5.183556, 
5.896377, 4.568287, 4.962494, 5.661899, 4.693507, 5.09624, 4.952923, 
4.985445, 5.16135, 5.53926, 5.225016, 4.528621, 5.319315, 5.113182, 
6.34168, 6.797491, 5.17235, 6.439498, 5.900781, 6.063498, 5.005395, 
5.982351, 5.160334, 6.159461, 5.454923, 5.302567, 5.917977, 5.390592, 
5.290922, 5.932603, 6.234784, 5.443459, 4.887867, 5.363649, 5.992517, 
5.59605, 6.957836, 5.96489, 6.010728, 6.699906, 5.593961, 5.090041, 
5.140206, 5.787355, 4.974325, 4.921738, 5.480681, 5.187052, 5.226022, 
5.069266, 5.237025, 4.95321, 4.710722, 5.958663, 5.57953, 6.11113, 
5.927328, 5.593754, 5.60118, 5.923102, 5.014739, 5.140896, 5.449914, 
5.780164, 5.861478, 5.557362, 5.425347, 4.878382, 7.208457, 5.156118, 
6.780757, 4.290224, 4.870924, 4.679899, 6.208831, 5.590676, 6.300666, 
4.933198, 6.825824, 4.871244, 5.002605, 4.663393, 5.265108, 5.084682, 
4.644537, 5.002514, 4.564025, 4.909876, 4.653416, 4.749584, 5.398681, 
4.987223, 4.896196, 5.126466, 5.990577, 5.20347, 5.84096, 4.575957, 
5.111575, 4.892085, 4.779402, 4.918394, 4.368466, 4.865299, 4.694033, 
4.432842, 4.387039, 5.293187, 4.667441, 5.066751, 4.532584, 5.427399, 
5.023701, 4.67848, 5.472184, 4.722462, 4.414159, 5.753562, 4.419682, 
4.986539, 4.399306, 6.545478, 4.845716, 6.44555, 6.310853, 5.904068, 
6.261015, 5.180911, 4.470479, 5.735125, 4.749411, 5.409848, 5.051328, 
5.892058, 6.309414, 5.437746, 5.096786, 5.318975, 5.364006, 5.009013, 
5.008035, 5.150562, 4.773881, 5.093893, 5.302292, 4.629325, 4.77105, 
5.606032, 6.115049, 4.913735, 6.225261, 5.837771, 6.528737, 5.071634, 
5.973802, 5.944085, 5.981799, 4.745119, 4.996573, 5.685109, 5.52415, 
5.07089, 5.368083, 4.72771, 6.224888, 6.062207, 5.030182, 5.295756, 
4.849476, 5.454442, 5.079627, 6.749876, 5.482995, 5.404961, 5.980376, 
4.609564, 5.841406, 5.099425, 4.606304, 5.343969, 6.558619, 4.833539, 
5.402571, 5.397597, 5.351819, 6.195629, 4.968225, 6.648347, 5.471629, 
5.77434, 5.642228, 5.992612, 6.438188, 5.197147, 7.102275, 5.676561, 
5.844794, 5.820053, 5.273107, 5.296794, 6.50132, 5.989487, 5.810758, 
5.140857, 5.933949, 7.191617, 5.409866, 6.47588, 6.272659, 5.398814, 
7.264528, 5.818978, 4.808685, 5.91949, 5.597109, 4.773778, 5.60327, 
6.297859, 5.036076, 5.580978, 5.374182, 6.098891, 5.228106, 4.514317, 
6.330842, 6.361819, 5.496118, 5.788364, 5.490537, 6.094959, 5.299442, 
4.654002, 4.653685, 6.423289, 5.8907, 5.44531, 5.082254, 5.408636, 
4.655344)), row.names = c(NA, 513L), class = "data.frame")

Overall the melted data has 4 columns and 11,286 rows. The first column, i.e. the "Row.names" shall contribute to the y-axis of the heat plot, and the third column, i.e. "variable" to contribute to the x-axis but they should be sectioned into four sections depending on the entries in the second column, i.e. "X1".

I'm attaching an image showing the two-section heat plot along the x-axis. enter image description here

Here the tiny white space separation shows the start of a new section on the x-axis.

My attempt can be found here:

tdfdarkmagentaplot<-ggplot(data=tdfdarkmagenta1, mapping=aes(variable, Row.names , fill= value))  
    geom_tile()   theme(axis.title.x=element_blank(),
                        axis.text.x=element_blank(),
                        axis.ticks.x=element_blank(),
                        axis.title.y=element_blank(),
                        axis.text.y=element_blank(),
                        axis.ticks.y=element_blank()) 
    scale_fill_distiller(palette = "RdBu")
tdfdarkmagentaplot

I'm also being told complexheatmap() function in R is another approach but don't know how to implement it in my dataframe.

All the suggestions are welcomed.

CodePudding user response:

Add facet wrap and indicate four columns.

ggplot(df[1:500,], aes(x = variable, y = Row.names, fill = value))  
    geom_tile()   
    theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank())  
    scale_fill_distiller(palette = "RdBu")  
    facet_wrap(~X1, ncol = 4)

I attempted to use your data. There were some NA values. The scales don't seem to match what you used. Anyhow, this shows what I believe is your desired column layout.

solution

  • Related