{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Load Python packages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/annadanese/opt/anaconda3/lib/python3.7/site-packages/scanpy/api/__init__.py:7: FutureWarning: \n",
      "\n",
      "In a future version of Scanpy, `scanpy.api` will be removed.\n",
      "Simply use `import scanpy as sc` and `import scanpy.external as sce` instead.\n",
      "\n",
      "  FutureWarning,\n"
     ]
    }
   ],
   "source": [
    "import rpy2\n",
    "# enables the %%R magic\n",
    "%load_ext rpy2.ipython\n",
    "\n",
    "from rpy2 import robjects\n",
    "import rpy2.robjects as robjects\n",
    "from rpy2.robjects.packages import importr\n",
    "readRDS = robjects.r['readRDS']\n",
    "\n",
    "import pandas as pd\n",
    "from warnings import warn\n",
    "\n",
    "\n",
    "import episcanpy.api as epi\n",
    "import scanpy as sc\n",
    "import anndata as ad\n",
    "\n",
    "import anndata2ri\n",
    "anndata2ri.activate()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "rpy2 -->  0.7.1\n",
      "anndata2ri --> 0.0.0\n",
      "anndata --> 0.7.1\n",
      "scanpy --> 1.4.7.dev1+g05703097\n",
      "episcanpy --> 0.1.10+3.g70e568e\n"
     ]
    }
   ],
   "source": [
    "#import episcanpy\n",
    "print('rpy2 --> ', ad.__version__)\n",
    "print('anndata2ri -->', anndata2ri.__version__)\n",
    "print('anndata -->', ad.__version__)\n",
    "print('scanpy -->', sc.__version__)\n",
    "print('episcanpy -->', epi.__version__)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "rpy2 -->  0.7.3\n",
      "anndata2ri --> 1.0.2\n",
      "anndata --> 0.7.3\n",
      "scanpy --> 1.5.1\n",
      "episcanpy --> 0.2.0\n"
     ]
    }
   ],
   "source": [
    "print('rpy2 --> ', ad.__version__)\n",
    "print('anndata2ri -->', anndata2ri.__version__)\n",
    "print('anndata -->', ad.__version__)\n",
    "print('scanpy -->', sc.__version__)\n",
    "print('episcanpy -->', epi.__version__)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Load R package(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "               _                           \n",
      "platform       x86_64-apple-darwin13.4.0   \n",
      "arch           x86_64                      \n",
      "os             darwin13.4.0                \n",
      "system         x86_64, darwin13.4.0        \n",
      "status                                     \n",
      "major          3                           \n",
      "minor          6.1                         \n",
      "year           2019                        \n",
      "month          07                          \n",
      "day            05                          \n",
      "svn rev        76782                       \n",
      "language       R                           \n",
      "version.string R version 3.6.1 (2019-07-05)\n",
      "nickname       Action of the Toes          \n"
     ]
    }
   ],
   "source": [
    "%%R \n",
    "R.version"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### import R's \"SnapATAC\" package"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "ename": "PackageNotInstalledError",
     "evalue": "The R package \"SnapATAC\" is not installed.",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mPackageNotInstalledError\u001b[0m                  Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-4-45e91472dee0>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0msnapatac\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mimportr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'SnapATAC'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;32m~/opt/anaconda3/lib/python3.7/site-packages/rpy2/robjects/packages.py\u001b[0m in \u001b[0;36mimportr\u001b[0;34m(name, lib_loc, robject_translations, signature_translation, suppress_messages, on_conflict, symbol_r2python, symbol_resolve, data)\u001b[0m\n\u001b[1;32m    469\u001b[0m     \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0misinstalled\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlib_loc\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlib_loc\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    470\u001b[0m         raise PackageNotInstalledError(\n\u001b[0;32m--> 471\u001b[0;31m             \u001b[0;34m'The R package \"%s\" is not installed.'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    472\u001b[0m         )\n\u001b[1;32m    473\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mPackageNotInstalledError\u001b[0m: The R package \"SnapATAC\" is not installed."
     ]
    }
   ],
   "source": [
    "snapatac = importr('SnapATAC')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### If you need to install SnapATAC:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "R[write to console]: Downloading GitHub repo r3fang/SnapATAC@master\n",
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "These packages have more recent versions available.\n",
      "Which would you like to update?\n",
      "\n",
      " 1:   All\n",
      " 2:   CRAN packages only\n",
      " 3:   None\n",
      " 4:   MASS        (7.3-51.3 -> 7.3-51.6) [CRAN]\n",
      " 5:   Matrix      (1.2-17   -> 1.2-18  ) [CRAN]\n",
      " 6:   R6          (2.4.0    -> 2.4.1   ) [CRAN]\n",
      " 7:   Rcpp        (1.0.1    -> 1.0.5   ) [CRAN]\n",
      " 8:   backports   (1.1.4    -> 1.1.8   ) [CRAN]\n",
      " 9:   callr       (3.2.0    -> 3.4.3   ) [CRAN]\n",
      "10:   cli         (1.1.0    -> 2.0.2   ) [CRAN]\n",
      "11:   digest      (0.6.18   -> 0.6.25  ) [CRAN]\n",
      "12:   ellipsis    (0.1.0    -> 0.3.1   ) [CRAN]\n",
      "13:   evaluate    (0.13     -> 0.14    ) [CRAN]\n",
      "14:   fansi       (0.4.0    -> 0.4.1   ) [CRAN]\n",
      "15:   foreach     (1.4.4    -> 1.5.0   ) [CRAN]\n",
      "16:   ggplot2     (3.1.1    -> 3.3.2   ) [CRAN]\n",
      "17:   glue        (1.3.1    -> 1.4.1   ) [CRAN]\n",
      "18:   iterators   (1.0.10   -> 1.0.12  ) [CRAN]\n",
      "19:   lattice     (0.20-38  -> 0.20-41 ) [CRAN]\n",
      "20:   mgcv        (1.8-28   -> 1.8-31  ) [CRAN]\n",
      "21:   nlme        (3.1-139  -> 3.1-148 ) [CRAN]\n",
      "22:   pillar      (1.3.1    -> 1.4.6   ) [CRAN]\n",
      "23:   pkgbuild    (1.0.3    -> 1.1.0   ) [CRAN]\n",
      "24:   pkgconfig   (2.0.2    -> 2.0.3   ) [CRAN]\n",
      "25:   pkgload     (1.0.2    -> 1.1.0   ) [CRAN]\n",
      "26:   plyr        (1.8.4    -> 1.8.6   ) [CRAN]\n",
      "27:   prettyunits (1.0.2    -> 1.1.1   ) [CRAN]\n",
      "28:   processx    (3.3.0    -> 3.4.3   ) [CRAN]\n",
      "29:   ps          (1.3.0    -> 1.3.4   ) [CRAN]\n",
      "30:   rlang       (0.3.4    -> 0.4.7   ) [CRAN]\n",
      "31:   rstudioapi  (0.10     -> 0.11    ) [CRAN]\n",
      "32:   scales      (1.0.0    -> 1.1.1   ) [CRAN]\n",
      "33:   sp          (1.3-1    -> 1.4-2   ) [CRAN]\n",
      "34:   tibble      (2.1.1    -> 3.0.3   ) [CRAN]\n",
      "35:   withr       (2.1.2    -> 2.2.0   ) [CRAN]\n",
      "Enter one or more numbers separated by spaces, or an empty line to cancel\n",
      "1: 3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "R[write to console]: Installing 26 packages: GenomeInfoDb, GenomicRanges, IRanges, RANN, RCurl, Rhdf5lib, Rtsne, S4Vectors, XVector, bigmemory, bigmemory.sri, doParallel, edgeR, farver, igraph, irlba, isoband, lifecycle, limma, locfit, raster, rhdf5, testthat, vctrs, viridis, zlibbioc\n",
      "\n",
      "R[write to console]: also installing the dependencies ‘rlang’, ‘sp’, ‘ellipsis’\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/rlang_0.4.7.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 847308 bytes (827 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 827 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/sp_1.4-2.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 1135318 bytes (1.1 MB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 1.1 MB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/ellipsis_0.3.1.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 7582 bytes\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 7582 bytes\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://bioconductor.org/packages/3.8/bioc/src/contrib/GenomeInfoDb_1.18.2.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 3404667 bytes (3.2 MB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 3.2 MB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://bioconductor.org/packages/3.8/bioc/src/contrib/GenomicRanges_1.34.0.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 1159067 bytes (1.1 MB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 1.1 MB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://bioconductor.org/packages/3.8/bioc/src/contrib/IRanges_2.16.0.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 457397 bytes (446 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 446 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/RANN_2.6.1.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 58136 bytes (56 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 56 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/RCurl_1.98-1.2.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 699583 bytes (683 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 683 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://bioconductor.org/packages/3.8/bioc/src/contrib/Rhdf5lib_1.4.3.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 9222338 bytes (8.8 MB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 8.8 MB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/Rtsne_0.15.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 67595 bytes (66 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 66 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://bioconductor.org/packages/3.8/bioc/src/contrib/S4Vectors_0.20.1.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 633420 bytes (618 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 618 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://bioconductor.org/packages/3.8/bioc/src/contrib/XVector_0.22.0.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 64494 bytes (62 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 62 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/bigmemory_4.5.36.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 70120 bytes (68 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 68 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/bigmemory.sri_0.1.3.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 1790 bytes\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 1790 bytes\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/doParallel_1.0.15.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 173578 bytes (169 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 169 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://bioconductor.org/packages/3.8/bioc/src/contrib/edgeR_3.24.3.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 1470609 bytes (1.4 MB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 1.4 MB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/farver_2.0.3.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 1279579 bytes (1.2 MB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 1.2 MB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/igraph_1.2.5.tar.gz'\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 2726569 bytes (2.6 MB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 2.6 MB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/irlba_2.3.3.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 234753 bytes (229 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 229 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/isoband_0.2.2.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 2295931 bytes (2.2 MB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 2.2 MB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/lifecycle_0.2.0.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 164455 bytes (160 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 160 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://bioconductor.org/packages/3.8/bioc/src/contrib/limma_3.38.3.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 1471609 bytes (1.4 MB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 1.4 MB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/locfit_1.5-9.4.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 200998 bytes (196 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 196 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/raster_3.3-13.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 574517 bytes (561 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 561 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://bioconductor.org/packages/3.8/bioc/src/contrib/rhdf5_2.26.2.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 504692 bytes (492 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 492 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/testthat_2.3.2.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 249661 bytes (243 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 243 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/vctrs_0.3.2.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 958372 bytes (935 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 935 KB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://cloud.r-project.org/src/contrib/viridis_0.5.1.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 1906320 bytes (1.8 MB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 1.8 MB\n",
      "\n",
      "\n",
      "R[write to console]: versuche URL 'https://bioconductor.org/packages/3.8/bioc/src/contrib/zlibbioc_1.28.0.tar.gz'\n",
      "\n",
      "R[write to console]: Content type 'application/x-gzip'\n",
      "R[write to console]:  length 257463 bytes (251 KB)\n",
      "\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: =\n",
      "R[write to console]: \n",
      "\n",
      "R[write to console]: downloaded 251 KB\n",
      "\n",
      "\n",
      "R[write to console]: Fehler in i.p(...) : \n",
      "  (konvertiert von Warnung) installation of package ‘rlang’ had non-zero exit status\n",
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Fehler in i.p(...) : \n",
      "  (konvertiert von Warnung) installation of package ‘rlang’ had non-zero exit status\n"
     ]
    }
   ],
   "source": [
    "%%R\n",
    "#install.packages(\"devtools\", repos='https://ftp.igh.cnrs.fr/pub/CRAN/', dependencies=TRUE, quiet=TRUE)\n",
    "#devtools::install_github(\"hadley/devtools\")\n",
    "#library(devtools)\n",
    "#install_github(\"r3fang/SnapATAC\")\n",
    "install_github(\"r3fang/SnapATAC\", repo=NULL, type=\"source\")\n",
    "#install.packages(\"SnapATAC\", repos='https://ftp.igh.cnrs.fr/pub/CRAN/', dependencies=TRUE, quiet=TRUE)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%R\n",
    "#install.packages(\"rlang\", repo=NULL, type=\"source\")\n",
    "library(sp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "R[write to console]: also installing the dependencies ‘sys’, ‘ps’, ‘askpass’, ‘fs’, ‘gh’, ‘git2r’, ‘glue’, ‘processx’, ‘fansi’, ‘promises’, ‘openssl’, ‘xopen’, ‘usethis’, ‘callr’, ‘cli’, ‘covr’, ‘DT’, ‘ellipsis’, ‘httr’, ‘jsonlite’, ‘pkgbuild’, ‘pkgload’, ‘rcmdcheck’, ‘rlang’, ‘sessioninfo’, ‘commonmark’, ‘purrr’, ‘yaml’, ‘xfun’\n",
      "\n",
      "\n",
      "R[write to console]: Updating HTML index of packages in '.Library'\n",
      "\n",
      "R[write to console]: Making 'packages.html' ...\n",
      "R[write to console]:  done\n",
      "\n"
     ]
    }
   ],
   "source": [
    "%%R\n",
    "#install.packages(\"devtools\", repos='https://ftp.igh.cnrs.fr/pub/CRAN/', quiet=TRUE)\n",
    "install.packages(c(\"devtools\", \"roxygen2\", \"testthat\", \"knitr\"),\n",
    "                 repos='https://ftp.igh.cnrs.fr/pub/CRAN/',\n",
    "                 quiet=TRUE)\n",
    "#devtools::install_github(\"hadley/devtools\")\n",
    "#library(devtools)\n",
    "#install_github(\"r3fang/SnapATAC\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "R[write to console]: Fehler in library(devtools) : es gibt kein Paket namens ‘devtools’\n",
      "\n",
      "R[write to console]: Zusätzlich: \n",
      "R[write to console]: Es gab 50 oder mehr Warnungen (Anzeige der ersten 50 mit warnings())\n",
      "R[write to console]: \n",
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Fehler in library(devtools) : es gibt kein Paket namens ‘devtools’\n"
     ]
    }
   ],
   "source": [
    "%%R\n",
    "library(devtools)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Load functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def digRS4(RS4, verbose=True):\n",
    "    \"\"\"\n",
    "    Extract elements of an RS4 object.\n",
    "    \n",
    "    \"\"\"\n",
    "    output_list = [type(RS4), RS4.rclass, RS4.slots.keys()]\n",
    "    \n",
    "    if verbose:\n",
    "        print('running function digRS4')\n",
    "        print(type(RS4), RS4.rclass)\n",
    "        print('elements of the RS4', RS4.slots.keys())\n",
    "        \n",
    "    # go through the different elements, extract the data and store it in a list\n",
    "    for i in tuple(RS4.slots.keys()):\n",
    "        list_type = []\n",
    "        type_i = type(RS4.slots[i]) # extract the type of the element extracted. \n",
    "        if verbose:\n",
    "            print(tuple(RS4.rclass), '\\t', i, type(RS4.slots[i]))\n",
    "        # if the element is not an RS4 you simply store it in the list\n",
    "        if type_i != rpy2.robjects.methods.RS4:\n",
    "            list_type.append(RS4.slots[i])\n",
    "        # if the element is an RS4 we call this function to go one step deeper \n",
    "        ### WARNING: need to check it is not and endless loop\n",
    "        else:\n",
    "            if verbose:\n",
    "                print('ERROR: RS4 object containing RS4')\n",
    "            list_type.append(digRS4(RS4.slots[i], verbose=verbose))\n",
    "        output_list.append(list_type)\n",
    "    return(output_list)\n",
    "\n",
    "\n",
    "def extract_snap(rds_file_name, verbose=True):\n",
    "    \"\"\"\n",
    "    reads an rds file containing a snap object. \n",
    "    Outputs an anndata matrix\n",
    "    \n",
    "    Warning:\n",
    "    the current version do not transfer Granges information\n",
    "    \n",
    "    Input:\n",
    "    ------\n",
    "    \n",
    "    rds_file_name --> file name, it had to be an rds file\n",
    "    \n",
    "    verbosity --> If True, prints information regarding the different steps to read\n",
    "    and convert thesnap object into an anndata.\n",
    "    \n",
    "    save --> if a file name specified, it will save the file as h5ad\n",
    "    \n",
    "    Output:\n",
    "    -------\n",
    "    Anndata object\n",
    "    \n",
    "    \"\"\"\n",
    "    #### Load the snao object and check what's in it\n",
    "    if verbose:\n",
    "        print('READ THE RDS FILE:\\n')\n",
    "    snap = readRDS(rds_file_name)\n",
    "    \n",
    "    \n",
    "    if verbose:\n",
    "        # print the type and the class of snap\n",
    "        print(type(snap), tuple(snap.rclass))\n",
    "        # print keys\n",
    "        print('keys: \\t', tuple(snap.slots.keys()))\n",
    "    if 'snap' not in tuple(snap.rclass):\n",
    "        warn('ERROR, the input file needs to be an rds file containing a snap object\\n')\n",
    "        return()\n",
    "    elif verbose:\n",
    "        print('continue with the snap object.\\n\\n\\n')\n",
    "    \n",
    "    ############\n",
    "    ###  extract the different elements of the snap object:\n",
    "    if verbose:\n",
    "        print('EXTRACT ELEMENTS COMPOSING THE SNAP OBJECT:\\n')\n",
    "        \n",
    "    #extract all elements to export into the Anndata that are not RS4 themself\n",
    "    elements = {}\n",
    "    # go through the individual elements of the snap object\n",
    "    for n in tuple(snap.slots.keys()):\n",
    "        if verbose:\n",
    "            print(n, type(snap.slots[n]))\n",
    "            \n",
    "        #######\n",
    "        # the case of RS4 and GRanges\n",
    "        if type(snap.slots[n]) == rpy2.robjects.methods.RS4 and ('GRanges' in snap.slots[n].rclass):\n",
    "            \n",
    "            tmp_list = [type(snap.slots[n]), tuple(snap.slots[n].rclass)]\n",
    "            warn(''.join(['\\n', n, 'partially excluded from the conversion.\\n GRanges are not currently fully transfered into the Anndata.\\n']))\n",
    "            granges = snap.slots[n]\n",
    "            tmp_list.append(tuple(granges.slotnames()))\n",
    "            \n",
    "            tmp_dict={}\n",
    "            for m in tuple(granges.slotnames()):\n",
    "                if verbose:\n",
    "                    print(m, type(granges.slots[m]))\n",
    "                # only salvage the elements that are not RS4\n",
    "                if type(granges.slots[m]) != rpy2.robjects.methods.RS4:\n",
    "                    tmp_dict[m] = granges.slots[m]\n",
    "                else:\n",
    "                    tmp_list2 = []\n",
    "                    tmp_feat = granges.slots[m]\n",
    "                    for p in tuple(tmp_feat.slotnames()):\n",
    "                        if verbose:\n",
    "                            print('\\t', p, type(tmp_feat.slots[p]))\n",
    "                        tmp_list2.append([p, type(tmp_feat.slots[p]), tmp_feat.slots[p]])\n",
    "                    \n",
    "                    tmp_dict[m] = [tuple(granges.slots[m].slotnames()), tmp_list2]\n",
    "                tmp_list.append(tmp_dict)\n",
    "\n",
    "            elements[n] = tmp_list\n",
    "            del tmp_list, tmp_list2, tmp_dict\n",
    "            if verbose:\n",
    "                print('\\n')\n",
    "        \n",
    "        #######\n",
    "        # the case of RS4 (not GRanges)\n",
    "        # if the object is an RS4 we will call a function toextract the subparts:\n",
    "        elif type(snap.slots[n]) == rpy2.robjects.methods.RS4:\n",
    "            if verbose:\n",
    "                print('\\nRS4 object: ', n, tuple(snap.slots[n].rclass), tuple(snap.slots[n].slotnames()), '\\n')\n",
    "                \n",
    "            ### call function\n",
    "            elements[n] = digRS4(RS4=snap.slots[n], verbose=verbose)\n",
    "            \n",
    "            \n",
    "        #######\n",
    "        # the rest of the cases\n",
    "        # if it is not an RS4 we simpoly convert it to a python data type and store it in the dictionary\n",
    "        else:\n",
    "            elements[n] = [type(snap.slots[n]), snap.slots[n]]\n",
    "            \n",
    "            \n",
    "    return(elements)\n",
    "\n",
    "\n",
    "def make_Anndata(input_data,\n",
    "                 mtx_name='bmat',\n",
    "                 feature_names=None,\n",
    "                 metadata_name='metaData', \n",
    "                 jaccard=True,\n",
    "                 jaccard_key='jmat',\n",
    "                 save_all_rds=False,\n",
    "                 save=None,\n",
    "                 copy=True):\n",
    "    \"\"\"\n",
    "    Currently, having multiple layers isn't possible.\n",
    "    It is possible to add the jaccard matrix.\n",
    "    \n",
    "    \"\"\"\n",
    "    \n",
    "    adata = ad.AnnData(X=input_data[mtx_name][1],\n",
    "            obs=input_data['metaData'][1])\n",
    "\n",
    "    if feature_names != None:\n",
    "        if 'GRanges' in input_data[feature_names][1]:\n",
    "            adata.var = input_data[feature_names][3]['elementMetadata']\n",
    "            \n",
    "    ## extra annotations ?\n",
    "    extra_annot = ['barcode', 'file', 'cluster', 'sample']\n",
    "    for extra in extra_annot:\n",
    "\n",
    "        if (extra in input_data.keys()) and (extra not in adata.obs.columns) and (len(input_data[extra][1].tolist()) == len(adata.obs_names.tolist())):\n",
    "            adata.obs[extra] = input_data[extra][1].tolist()\n",
    "            \n",
    "        \n",
    "    \n",
    "    # save the class snap:\n",
    "    if 'class' in input_data.keys():\n",
    "        adata.uns['class'] = input_data['class'][1]\n",
    "    \n",
    "    ## Add tsne, umap\n",
    "    for n in ['tsne', 'umap']:\n",
    "        if n in input_data.keys():\n",
    "            name = ''.join(['X_',n,'_snap'])\n",
    "            if input_data[n][1].shape == (len(adata.obs_names.tolist()), 2):\n",
    "                adata.obsm[name] = input_data[n][1]\n",
    "            else:\n",
    "                warn(''.join(['WARNING: the dimension of ',\n",
    "                              n,\n",
    "                              ' does not match the expected shape. Therefore it is stored in adata.uns\\n']))\n",
    "                adata.uns[name] = input_data[n]\n",
    "                \n",
    "            \n",
    "    if jaccard and (jaccard_key in input_data.keys()):\n",
    "        \n",
    "        ## check that the jaccard distance was computed properly\n",
    "        if mtx_name not in input_data[jaccard_key][8][0]:\n",
    "            warn(''.join(['WARNING: the jaccard distance is not computed using ', mtx_name, '\\n',\n",
    "                 'The jaccard distance was computed for: ', str(input_data[jaccard_key][8][0]), '\\n']))\n",
    "            \n",
    "        adata.uns['jaccard'] = {'index':input_data[jaccard_key][3][0],\n",
    "                                'normalised':input_data[jaccard_key][4][0],\n",
    "                                'params':{'mtx': input_data[jaccard_key][8][0],\n",
    "                                          'vector1': input_data[jaccard_key][5][0],\n",
    "                                          'vector2': input_data[jaccard_key][6][0]\n",
    "                                         }\n",
    "                               }\n",
    "    # save the rest in uns\n",
    "    if save_all_rds:\n",
    "        for n in input_data.keys():\n",
    "            adata.uns[n] = input_data[n]\n",
    "         \n",
    "    if save!=None:\n",
    "        save = save.rstrip('.h5ad')\n",
    "        adata.write('.'.join([save, 'h5ad']))\n",
    "        \n",
    "    if copy:\n",
    "        return(adata)\n",
    "    \n",
    "    \n",
    "    \n",
    "def snap2anndata(rds_file_name,\n",
    "                 path='',\n",
    "                 mtx_name='bmat',\n",
    "                 feature_names='feature',\n",
    "                 metadata_name='metaData', \n",
    "                 jaccard=True,\n",
    "                 jaccard_key='jmat',\n",
    "                 save_all_rds=False,\n",
    "                 verbose=False,\n",
    "                 copy=True,\n",
    "                 save=None):\n",
    "    \"\"\"\n",
    "    Convert a snap object saved as .rds into an Anndata object.\n",
    "    \n",
    "    In the current version of this function, you cannot store multiple matrices in \n",
    "    different layers of the anndata. \n",
    "    \n",
    "    Input:\n",
    "    ------\n",
    "    * rds_file_name [str] --> the name of the inpout file\n",
    "    \n",
    "    * path [str] --> the path to the rds file - default: ''\n",
    "    \n",
    "    * mtx_name [str] --> matrix/featurespace extracted for the anndata.X - default: 'bmat'\n",
    "    \n",
    "    * feature_names [NoneType or str] --> key to extract the variable names (stored as GRanges in\n",
    "      snap object) if specified - default: 'feature'\n",
    "    \n",
    "    * metadata_name [str] --> key to extract the metadata table from the snap object\n",
    "      (also includes the observation names)- default: 'metaData'\n",
    "    \n",
    "    * jaccard [bool] --> extract the jaccard distance if jaccard is True - default: True\n",
    "    \n",
    "    * jaccard_key [str] --> If jaccard is True, it will extract the jaccard information\n",
    "      stored in the snap object under the jaccard_key - default: 'jmat'\n",
    "    \n",
    "    * save_all_rds [bool] --> save the entire snap object in the uns section of the Anndata\n",
    "      object. It takes a lot of memory but can be used to extract the different count matrices\n",
    "      stored in the snap object - default: False\n",
    "    \n",
    "    * verbose [bool] --> print intermediary results and comments if True - default: False\n",
    "    \n",
    "    * copy [bool] --> if copy is True, return an Anndata object. - default: True\n",
    "    \n",
    "    * save [NoneType or str]--> if save is specified, write the Anndata as .h5ad\n",
    "       - default: None\n",
    "    \n",
    "    \n",
    "    Output\n",
    "    ------\n",
    "    \n",
    "    * Anndata object --> if copy=True\n",
    "    \n",
    "    * Write the anndata object (as h5ad)--> if the output file name is specified as save='output_name'.\n",
    "        If the path to the output directory is not specified with the output name, the anndata is saved in the current directory.\n",
    "    \n",
    "    \"\"\"\n",
    "    if path != '':\n",
    "        file_name = '/'+path.rstrip('/').lstrip('/')+'/'+ rds_file_name.lstrip('/')\n",
    "    else:\n",
    "        file_name = rds_file_name.lstrip('/')\n",
    "    \n",
    "    tmp_file = extract_snap(rds_file_name=file_name,\n",
    "                            verbose=verbose)\n",
    "    \n",
    "    if copy:\n",
    "        return(make_Anndata(input_data=tmp_file,\n",
    "                            mtx_name=mtx_name,\n",
    "                            feature_names=feature_names,\n",
    "                            metadata_name=metadata_name, \n",
    "                            jaccard=jaccard,\n",
    "                            jaccard_key=jaccard_key,\n",
    "                            save_all_rds=save_all_rds,\n",
    "                            save=save,\n",
    "                            copy=True))\n",
    "    else:\n",
    "        make_Anndata(input_data=tmp_file,\n",
    "                     mtx_name=mtx_name,\n",
    "                     feature_names=feature_names,\n",
    "                     metadata_name=metadata_name, \n",
    "                     jaccard=jaccard,\n",
    "                     jaccard_key=jaccard_key,\n",
    "                     save_all_rds=save_all_rds,\n",
    "                     save=save,\n",
    "                     copy=False)\n",
    "        "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Convert a snap object into an anndata"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " UserWarning:/Users/anna.danese/anaconda3/envs/new_snapatac/lib/python3.6/site-packages/ipykernel_launcher.py:89: \n",
      "featurepartially excluded from the conversion.\n",
      " GRanges are not currently fully transfered into the Anndata.\n",
      "\n",
      " UserWarning:/Users/anna.danese/anaconda3/envs/new_snapatac/lib/python3.6/site-packages/ipykernel_launcher.py:89: \n",
      "peakpartially excluded from the conversion.\n",
      " GRanges are not currently fully transfered into the Anndata.\n",
      "\n",
      " UserWarning:/Users/anna.danese/anaconda3/envs/new_snapatac/lib/python3.6/site-packages/ipykernel_launcher.py:181: WARNING: the dimension of umap does not match the expected shape. Therefore it is stored in adata.uns\n",
      "\n",
      "... storing 'file' as categorical\n",
      "... storing 'sample' as categorical\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "AnnData object with n_obs × n_vars = 4100 × 546206 \n",
       "    obs: 'barcode', 'total', 'duplicate', 'chimeric', 'unmapped', 'lowmapq', 'mitochondrial', 'passed_filters', 'cell_id', 'is__cell_barcode', 'TSS_fragments', 'DNase_sensitive_region_fragments', 'enhancer_region_fragments', 'promoter_region_fragments', 'on_target_fragments', 'blacklist_region_fragments', 'peak_region_fragments', 'peak_region_cutsites', 'promoter_ratio', 'landmark', 'cluster', 'file', 'sample'\n",
       "    var: 'name'\n",
       "    uns: 'class', 'X_umap_snap', 'jaccard'\n",
       "    obsm: 'X_tsne_snap'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "adata = snap2anndata(rds_file_name='atac_v1_adult_brain_fresh_5k.snap.rds',\n",
    "                 path='/Volumes/Hepatocytes/snapatac_to_episcanpy/',\n",
    "                 mtx_name='bmat',\n",
    "                 feature_names='feature',\n",
    "                 metadata_name='metaData', \n",
    "                 jaccard=True,\n",
    "                 jaccard_key='jmat',\n",
    "                 save_all_rds=False,\n",
    "                 verbose=False,\n",
    "                 copy=True,\n",
    "                 save='/Volumes/Hepatocytes/snapatac_to_episcanpy/atac_v1_adult_brain_fresh_5k.snap.h5ad')\n",
    "adata"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 47252 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "adata.obsm['X_tsne'] = adata.obsm['X_tsne_snap'].copy()\n",
    "sc.pl.tsne(adata, color='cluster')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
