From 11d9aa4747ec2fd2a430cc6bf52d3e4f7f76799b Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Wed, 6 Apr 2016 18:38:37 +0100 Subject: [PATCH 1/2] matrix heatmap plot range fix --- lib/Plot.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Plot.hpp b/lib/Plot.hpp index 57ffe65..6e2fdec 100644 --- a/lib/Plot.hpp +++ b/lib/Plot.hpp @@ -136,6 +136,20 @@ public: virtual ~PlotHistogram(void) = default; }; +class PlotMatrixNoRange: public PlotObject +{ +public: + // constructor + PlotMatrixNoRange(const DMat &m); + // destructor + virtual ~PlotMatrixNoRange(void) = default; +}; + +#define PlotMatrix(m)\ +PlotRange(Axis::x, -.5, (m).cols() - .5) <<\ +PlotRange(Axis::y, (m).rows() - .5, -.5) <<\ +PlotMatrixNoRange(m) + /****************************************************************************** * Plot modifiers * ******************************************************************************/ From de84137f2c3c39c2101116844bc8a3a2866a24d1 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Wed, 6 Apr 2016 18:39:03 +0100 Subject: [PATCH 2/2] external tool to plot correlation heatmap --- utils/Makefile.am | 5 ++++ utils/sample_plot_corr.cpp | 51 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 utils/sample_plot_corr.cpp diff --git a/utils/Makefile.am b/utils/Makefile.am index 75b2a77..d5a51b1 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -18,6 +18,7 @@ bin_PROGRAMS = \ latan_create_rg_state \ latan_make_fake_sample\ latan_sample_combine \ + latan_sample_plot_corr\ latan_sample_read \ latan_resample @@ -33,6 +34,10 @@ latan_sample_combine_SOURCES = sample_combine.cpp latan_sample_combine_CXXFLAGS = $(COM_CXXFLAGS) latan_sample_combine_LDFLAGS = -L../lib/.libs -lLatAnalyze +latan_sample_plot_corr_SOURCES = sample_plot_corr.cpp +latan_sample_plot_corr_CXXFLAGS = $(COM_CXXFLAGS) +latan_sample_plot_corr_LDFLAGS = -L../lib/.libs -lLatAnalyze + latan_sample_read_SOURCES = sample_read.cpp latan_sample_read_CXXFLAGS = $(COM_CXXFLAGS) latan_sample_read_LDFLAGS = -L../lib/.libs -lLatAnalyze diff --git a/utils/sample_plot_corr.cpp b/utils/sample_plot_corr.cpp new file mode 100644 index 0000000..2f540f5 --- /dev/null +++ b/utils/sample_plot_corr.cpp @@ -0,0 +1,51 @@ +/* + * sample_plot_corr.cpp, part of LatAnalyze 3 + * + * Copyright (C) 2013 - 2016 Antonin Portelli + * + * LatAnalyze 3 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * LatAnalyze 3 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LatAnalyze 3. If not, see . + */ + +#include +#include +#include +#include + +using namespace std; +using namespace Latan; +using namespace Math; + +int main(int argc, char *argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " " << endl; + + return EXIT_FAILURE; + } + + string fileName = argv[1], name; + DMatSample sample; + DMat var; + Plot p; + + cout << "-- computing variance matrix from '" << fileName << "'..." << endl; + name = Io::getFirstName(fileName); + sample = Io::load(fileName); + var = sample.varianceMatrix(); + p << PlotMatrix(varToCorr(var)); + p.display(); + + return EXIT_SUCCESS; +}