Skip to content

Running a faster version of Rtsne

Theorell edited this page Sep 17, 2018 · 2 revisions

If you have large datasets (i.e. more than 10000 events), I am sure you would like your SNE calculations to have a shorter duration than what Rtsne gives you. There is help to get, nicely enough! For Windows and Linux users, it is really straight forward: library(devtools)

install_github("jkrijthe/Rtsne", ref="openmp")

For OSX users, this is (unveliveably still) a bit harder, as there is no openMP support in the standard clang compilers (leading to a constant problem when very fast implementations of R packages should be implemented). There is a constant rumor that this should change, but it has been an apparent problem over the past three years. There are different ways around it though, but the one that has worked for me is found at the citrus package installation page. I will repeat it here, to make it more accessible:

First, download and install Xcode and install the Xcode command line tools by opening the Terminal (found among the Utilities) and typing:

xcode-select --install

After this, download and install macports

I hope you are still with me. Now we are ready to start preparing for the actual installation.

Open the terminal again and type:

sudo port install gcc48

to install a gcc compiler that will be used instead of the standard clang compilers.

g++-mp-4.8 -v

Now tell R to use our newly installed version of g++. Open a terminal and use a text editor to create the ~/.R/Makevars file: mkdir ~/.R shell> nano ~/.R/Makevars

Add the following lines to the text file:

CXX=/opt/local/bin/g++-mp-4.8 -arch x86_64 CC=/opt/local/bin/gcc-mp-4.8 SHLIB_OPENMP_CXXFLAGS= -fopenmp

If a line setting the CXX value already exists, replace it with the line above. Write changes and exit the editor. If you're using nano, type control-o, hit "enter", and then control-x.

Start R and re-install Rtsne: library(devtools)

install_github("jkrijthe/Rtsne", ref="openmp")

I hope this works for people! As I wrote in the beginning, there are multiple ways to get openMP-support, but this is the only one that has consistently worked for me on different computers. If this does not work, it is actually worth some hours of trial and error, as the openMP-version of Rtsne is very, very much faster than the standard implementation.

Clone this wiki locally