Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 221 lines (183 sloc) 6.223 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage[top=1.5cm, bottom=1.5cm,left=2cm,right=1.5cm]{geometry}
%\usepackage{url}
\usepackage{listings}

%opening
\title{Statistical Analysis of ISMB 2012 Coverage at Twitter}
\author{Neil Saunders}

\begin{document}
\lstset{breaklines=true}
\SweaveOpts{concordance=TRUE}
\maketitle

\section{Preamble}
Load required libraries and data.
%load data
<<echo=TRUE, results=hide>>=
library(ggplot2)
library(xtable)
library(RColorBrewer)
library(tm)
library(wordcloud)
library(sentiment)
load("../../data/ismb.RData")
@

\section{Tweets per day}
\begin{center}
\setkeys{Gin}{width=0.6\textwidth}
<<fig=TRUE, echo=TRUE>>=
ismb$date <- as.Date(ismb$created)
byDay <- as.data.frame(table(ismb$date))
colnames(byDay) <- c("date", "tweets")
print(ggplot(byDay) + geom_bar(aes(date, tweets), fill = "salmon") + theme_bw()
      + opts(title = "ISMB 2012 tweets per day"))
@
\end{center}

\newpage

\section{Tweets per hour by day}
\begin{center}
<<fig=TRUE, echo=TRUE>>=
ismb$hour <- as.POSIXlt(ismb$created)$hour
byDayHour <- as.data.frame(table(ismb$date, ismb$hour))
colnames(byDayHour) <- c("date", "hour", "tweets")
byDayHour$hour <- as.numeric(as.character(byDayHour$hour))
print(ggplot(byDayHour) + geom_bar(aes(hour, tweets), fill = "salmon", binwidth = 1) +
  facet_grid(date ~ hour) +
  opts(axis.text.x = theme_blank(),
       axis.ticks = theme_blank(),
       panel.background = theme_blank(),
       title = "ISMB 2012 tweets per hour by day"))
@
\end{center}

\newpage

\section{Popular talks}
First, get the hashtags:
<<echo=TRUE, results=verbatim>>=
words <- strsplit(ismb$text, " ")
hashtags <- lapply(words, function(x) x[grep("^#", x)])
hashtags <- unlist(hashtags)
hashtags <- tolower(hashtags)
hashtags <- gsub("[^A-Za-z0-9]", "", hashtags)
ht <- as.data.frame(table(hashtags))
ht <- ht[sort.list(ht$Freq, decreasing=F),]
@

\subsection{Keynotes}
\begin{center}
<<echo=TRUE, fig=TRUE>>=
kn <- ht[grep("^kn", ht$hashtags),]
kn$hashtags <- factor(kn$hashtags, levels = as.character(kn$hashtags))
print(ggplot(tail(kn)) + geom_bar(aes(hashtags, Freq), fill = "salmon") +
  coord_flip() + theme_bw() + opts(title = "ISMB 2012 tweets - keynotes"))
@
\end{center}

KN 3: Analysis of transcriptome structure and chromatin landscapes (Barbara Wold).

\newpage

\subsection{Published Papers}
\begin{center}
<<echo=TRUE, fig=TRUE>>=
pp <- ht[grep("^pp", ht$hashtags),]
pp[47,2] <- 39
pp <- pp[-5,]
pp$hashtags <- factor(pp$hashtags, levels = as.character(pp$hashtags))
print(ggplot(tail(pp, 20)) + geom_bar(aes(hashtags, Freq), fill = "salmon") +
  coord_flip() + theme_bw() + opts(title = "ISMB 2012 tweets - published papers"))
@
\end{center}

PP 44: Toward interoperable bioscience data (Susanna-Assunta Sansone).

\newpage

\subsection{Special Sessions}
\begin{center}
<<echo=TRUE, fig=TRUE>>=
ss <- ht[grep("^ss", ht$hashtags),]
ss$hashtags <- factor(ss$hashtags, levels = as.character(ss$hashtags))
print(ggplot(ss) + geom_bar(aes(hashtags, Freq), fill = "salmon") +
  coord_flip() + theme_bw() + opts(title = "ISMB 2012 tweets - special sessions"))
@
\end{center}

SS 4: Bioinformatic Integration of Diverse Experimental Data Sources (Kyle Ellrott, David Haussler, Artem Sokolov, Josh Stuart).

\newpage

\subsection{Technology Track}
\begin{center}
<<echo=TRUE, fig=TRUE>>=
tt <- ht[grep("^tt", ht$hashtags),]
tt$hashtags <- factor(tt$hashtags, levels = as.character(tt$hashtags))
print(ggplot(tail(tt, 20)) + geom_bar(aes(hashtags, Freq), fill = "salmon") +
  coord_flip() + theme_bw() + opts(title = "ISMB 2012 tweets - technology track"))
@
\end{center}

TT06: The Taverna Server - Executing Scientific Workflows Remotely (Katy Wolstencroft).

\newpage

\subsection{Workshops}
\begin{center}
<<echo=TRUE, fig=TRUE>>=
wk <- ht[grep("^wk", ht$hashtags),]
wk$hashtags <- factor(wk$hashtags, levels = as.character(wk$hashtags))
print(ggplot(wk) + geom_bar(aes(hashtags, Freq), fill = "salmon") +
  coord_flip() + theme_bw() + opts(title = "ISMB 2012 tweets - workshops"))
@
\end{center}

WK 3: Bioinformatics Core Facilities (Simon Andrews, Fran Lewitter, Brent Richter, David Sexton).

\newpage

\section{Users}
\subsection{The long tail}
\begin{center}
<<fig=TRUE, echo=TRUE>>=
users <- as.data.frame(table(ismb$screenName))
colnames(users) <- c("user", "tweets")
users <- users[sort.list(users$tweets, decreasing = T),]
print(ggplot(users) + geom_point(aes(1:nrow(users), tweets), color = "salmon") + theme_bw() +
  opts(title = "ISMB 2012 tweets per user") + xlab("User"))
@
\end{center}

\subsection{The top 10}
<<echo=FALSE,results=tex>>=
print(xtable(head(users, 10), caption = "Most tweets - top 10 users"), include.rownames = FALSE)
@

\newpage

\section{Text mining}
\subsection{Word frequency}
First, get all words composed only of alphanumeric characters.
<<echo=TRUE, results=tex>>=
sw <- stopwords("en")
words <- lapply(words, function(x) x[grep("^[A-Za-z0-9]+$", x)])
words <- unlist(words)
words <- tolower(words)
words <- words[-grep("^[rm]t$", words)]
words <- words[!words %in% sw]
words.t <- as.data.frame(table(words))
words.t <- words.t[sort.list(words.t$Freq, decreasing = T),]
print(xtable(head(words.t, 10), caption = "Top 10 words in tweets"), include.rownames = FALSE)
@

\setkeys{Gin}{width=0.6\textwidth}
\begin{center}
<<fig=TRUE, echo=TRUE>>=
pal2 <- brewer.pal(8, "Dark2")
wordcloud(words.t$words, words.t$Freq, scale = c(8, .2), min.freq = 3,
    max.words = 200, random.order = FALSE, rot.per = .15, colors = pal2)
@
\end{center}

\newpage

\subsection{Sentiment analysis}

\subsubsection{Emotions}
<<echo=TRUE, results=tex>>=
em <- classify_emotion(ismb$text, algorithm = "bayes")
print(xtable(table(em[, "BEST_FIT"]), caption = "Tweet emotion"))
@

Shall we look at a "joyous" tweet?

\begin{lstlisting}
\Sexpr{ismb$text[3]}
\end{lstlisting}

\subsubsection{Polarity}
<<echo=TRUE, results=tex>>=
po <- classify_polarity(ismb$text, algorithm = "bayes")
print(xtable(table(po[, "BEST_FIT"]), caption = "Tweet polarity"))
@

A "positive" tweet:
\begin{lstlisting}
\Sexpr{ismb$text[7]}
\end{lstlisting}

A "negative" tweet:
\begin{lstlisting}
\Sexpr{ismb$text[19]}
\end{lstlisting}

\end{document}
Something went wrong with that request. Please try again.