---
title: "Transform_to_feather"
author: "Florian Wuennemann"
date: "April 20, 2018"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Read Rds object

```{r}
library(feather)
library(microbenchmark)
library(tibble)
```


```{r}
test_rds <- readRDS("/home/florian/data/E14.5.clustering_module.Rds")
```

```{r}
## Read in data frames from RDS and save as feather
## tsne
write_feather(test_rds@tsne,"/home/florian/data/feather/E14.5.tsne.feather")

## Expression df
norm_exprs <- test_rds@norm_exprs
norm_exprs <- norm_exprs %>%
  rownames_to_column("gene")

write_feather(norm_exprs,"/home/florian/data/feather/E14.5.norm_exprs.feather")

## Metadata
write_feather(test_rds@metadata,"/home/florian/data/feather/E14.5.metadata.feather")

## Marker
write_feather(test_rds@marker_list,"/home/florian/data/feather/E14.5.marker_list.feather")
```

```{r}
benchmark_feather <- (microbenchmark(
  tsne <- read_feather("/home/florian/data/feather/E14.5.tsne.feather"),
  norm_exprs <- read_feather("/home/florian/data/feather/E14.5.norm_exprs_.feather"),
  metadata <- read_feather("/home/florian/data/feather/E14.5.metadata.feather"),
  marker_list <- read_feather("/home/florian/data/feather/E14.5.marker_list.feather"),times =10))
```

```{r}
benchmark_rds <- (microbenchmark(
  test_rds <- readRDS("/home/florian/data/E14.5.clustering_module.Rds"),
  tsne <- test_rds@tsne,
  norm_exprs <- test_rds@norm_exprs,
  metadata <- test_rds@metadata,
  marker_list <- test_rds@marker_list,times =10))
```


```{r}
print(benchmark_feather,signif = 2)
sum_mean_time_feather <- sum(benchmark_feather$mean)
autoplot(benchmark_feather)

print(benchmark_rds,signif = 2)
sum_mean_time_rds <- sum(benchmark_rds$mean)
autoplot(benchmark_rds)
```