knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
The goal of gardenr
is provide simple functions of analyzing the data from Gardener's interneuron classification as well as to provide examples of analyses of such data.
You can use the devtools
package to install gardenr
from Github.
devtools::install_github('ComputationalIntelligenceGroup/gardenr')
The user needs to provide the path to the folder containing the data. These can be downloaded from https://figshare.com/s/8a761698160a675bb080.
folder <- '/home/bmihaljevic/code-gardener/gardener-experiment-data/data/' library(tidyverse)
gardenr
functions return the data for all 320 cells. There are functions for the classification labels get_all_labels
, metadata get_all_meta
, and alternative type names and definitions get_alternative_types
.
library(gardenr) annotations <- get_all_labels(folder ) summary(annotations)
alternative <- get_alternative_types(folder) summary(alternative)
metadata <- get_all_meta(folder) summary(metadata)
To get data on a specific cell or annotator, we only need filter by id:
metadata %>% filter(neuron == 12) head(annotations %>% filter(neuron == 12))
head(annotations %>% filter(annotator == 2)) alternative %>% filter(annotator == 2)
It is easy to combine the three data frames using joins, and then compute summaries with tidyverse
functions. For example, the alternative type definition to an annotation
head(left_join(annotations, alternative, by = c("other" = "type", "annotator" = "annotator")))
The primary key in alternative
consits of annotator
and type
and hence we need both in the join.
There is a utility function to return the counts for all categories, with a single entry per neuron.
counts <- get_all_counts(folder) head(counts)
We can join the above with metadata to get thorough information for each cell.
meta_count <- left_join(counts, metadata, by = 'neuron') %>% select(-paper, -original.type, -archive, -neuromorpho.name) head(meta_count)
There is a utility function doing just that:
head(get_all_counts_meta(folder) )
These data are also available in a different format, which is a bit easier to analyze
annot_tidy <- make_annotations_tidy(annotations) head(annot_tidy )
table(annotations$complete)
annot_tidy <- make_annotations_tidy(annotations) annot_tidy %>% group_by(feature, value) %>% tally() # library(ggplot2) ggplot(annot_tidy, aes(x = value, color = feature)) + geom_bar() + theme(axis.text.x = element_text(angle = 90, hjust = 1))
annot_tidy <- make_annotations_tidy(annotations) above30 <- annot_tidy %>% group_by(neuron, feature, value) %>% tally() %>% filter(n > 30) above30 %>% group_by(feature) %>% summarize(n_distinct(neuron))
monkey <- metadata %>% filter(species == 'Monkey') counts <- get_all_counts_meta(folder) counts %>% filter(species == 'Monkey')
length(unique(alternative$annotator)) unique(alternative$annotator)
types <- alternative %>% group_by(annotator) %>% tally() other <- annotations %>% group_by(annotator) %>% filter(F5 == 'other') %>% tally() ggplot(data.frame(types = types$n, cells = other$n), aes(x = types, y = cells)) + geom_point()
library(tidytext) library(wordcloud) alt <- alternative alt$type <- as.character(alternative$type ) alt <- alt %>% unnest_tokens(type, type) alt %>% count(type, sort = TRUE) alt %>% count(type, sort = TRUE) %>% with(wordcloud(type, n, random.order = FALSE, max.words = 50 , colors= brewer.pal(8,"Dark2")))
alt <- alternative alt$definition <- as.character(alternative$definition ) alt <- alt %>% unnest_tokens(definition, definition) alt <- alt %>% anti_join(get_stopwords(), by = c("definition" = "word")) alt %>% count(definition, sort = TRUE) alt %>% count(definition, sort = TRUE) %>% with(wordcloud(definition, n, random.order = FALSE, max.words = 50 , colors= brewer.pal(8,"Dark2")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.