text:
\documentclass[oneside]{memoir}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
\else % if luatex or xelatex
  \ifxetex
    \usepackage{mathspec}
  \else
    \usepackage{fontspec}
  \fi
  \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}
\hypersetup{unicode=true,
            pdftitle={Geospatial in R},
            pdfauthor={LTC Melanie Vinton},
            pdfborder={0 0 0},
            breaklinks=true}
\urlstyle{same}  % don't use monospace font for urls
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{248,248,248}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\ImportTok}[1]{#1}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.81,0.36,0.00}{\textbf{#1}}}
\newcommand{\BuiltInTok}[1]{#1}
\newcommand{\ExtensionTok}[1]{#1}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.77,0.63,0.00}{#1}}
\newcommand{\RegionMarkerTok}[1]{#1}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.94,0.16,0.16}{#1}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.64,0.00,0.00}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{#1}
\usepackage{longtable,booktabs}
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{5}
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi

%%% Use protect on footnotes to avoid problems with footnotes in titles
\let\rmarkdownfootnote\footnote%
\def\footnote{\protect\rmarkdownfootnote}

%%% Change title format to be more compact
\usepackage{titling}

% Create subtitle command for use in maketitle
\newcommand{\subtitle}[1]{
  \posttitle{
    \begin{center}\large#1\end{center}
    }
}

\setlength{\droptitle}{-2em}
  \title{Geospatial in R}
  \pretitle{\vspace{\droptitle}\centering\huge}
  \posttitle{\par}
  \author{LTC Melanie Vinton}
  \preauthor{\centering\large\emph}
  \postauthor{\par}
  \predate{\centering\large\emph}
  \postdate{\par}
  \date{2017-11-14}

\usepackage{booktabs}
\usepackage{amsthm}
\makeatletter
\def\thm@space@setup{%
  \thm@preskip=8pt plus 2pt minus 4pt
  \thm@postskip=\thm@preskip
}
\makeatother

\usepackage{amsthm}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{lemma}{Lemma}[chapter]
\theoremstyle{definition}
\newtheorem{definition}{Definition}[chapter]
\newtheorem{corollary}{Corollary}[chapter]
\newtheorem{proposition}{Proposition}[chapter]
\theoremstyle{definition}
\newtheorem{example}{Example}[chapter]
\theoremstyle{definition}
\newtheorem{exercise}{Exercise}[chapter]
\theoremstyle{remark}
\newtheorem*{remark}{Remark}
\newtheorem*{solution}{Solution}
\begin{document}
\maketitle

{
\setcounter{tocdepth}{1}
\tableofcontents
}
\chapter{Geospatial Module Intro}\label{geospatial-module-intro}

** First, restart your R session.**

\begin{itemize}
\item
  There are multiple packages in R that allow you to ``roll your own
  maps'' without expensive and often not available GIS software.
\item
  These packages also offer functions to enable geospatial analysis and
  manipulation of spatial data.
\item
  The goal of this module is to demonstrate some simple methods for
  creating maps and displaying data on maps.
\item
  Geospatial Revolution video:
  \url{https://www.youtube.com/watch?v=ZdQjc30YPOk}
\end{itemize}

\chapter{Geospatial Module Intro}\label{geospatial-module-intro-1}

** First, restart your R session.**

\begin{itemize}
\item
  There are multiple packages in R that allow you to ``roll your own
  maps'' without expensive and often not available GIS software.
\item
  These packages also offer functions to enable geospatial analysis and
  manipulation of spatial data.
\item
  The goal of this module is to demonstrate some simple methods for
  creating maps and displaying data on maps.
\item
  Geospatial Revolution video:
  \url{https://www.youtube.com/watch?v=ZdQjc30YPOk}
\end{itemize}

\chapter{Geospatial Basics}\label{geospatial-basics}

\begin{itemize}
\item
  Geospatial analysis is:

  \begin{itemize}
  \tightlist
  \item
    The use of data and technology to explore geography and geo
    problems.
  \item
    Comparing things across space and time.\\
  \item
    Taking location into account and leveraging spatial relationships to
    answer questions.
  \end{itemize}
\item
  Tobler's first law of geography: everything is related to everything
  else, but near things are more related than far things.
\item
  Maps are:

  \begin{itemize}
  \tightlist
  \item
    A simplification of reality.
  \item
    A way to display data, tell stories, and influence understanding and
    decision making.
  \end{itemize}
\end{itemize}

\section{Projections}\label{projections}

\emph{The earth is round and maps are flat.}

\begin{itemize}
\item
  Projections transform location information from a 3D sphere to a 2D
  map, preserving some \emph{but not all} attributes.
\item
  Projections use coordinates and coordinate reference systems to do the
  transformation.
\item
  Different projections can produce different results in geospatial
  analysis.
\end{itemize}

Coordinate Reference Systems:

\begin{itemize}
\item
  Coordinate Reference Systems (also called Geodetic Datums) are a
  coordinate system and a set of reference points used to locate places
  on Earth by defining the geometric relationship between the coordinate
  system grid and the Earth's surface.
\item
  A common datum is WGS84 but there are many others.
\end{itemize}

\section{Coordinate Formats}\label{coordinate-formats}

\begin{itemize}
\item
  A geographic coordinate system is a reference system used to represent
  any location on Earth within a common geographic framework (such as
  longitude and latitude) using letters, numbers, or symbols.

  \begin{itemize}
  \item
    Longitude: East-West from the Prime Meridian, lines go up and down
    to the poles, not parallel, ``x'' on the cartisian scale
  \item
    Latitude: North-South from the Equator, parallel lines, ``y'' on the
    Cartesian scale
  \end{itemize}
\item
  Some common Coordinate Systems you may be familiar with:

  \begin{itemize}
  \item
    Military Grid Reference System (MGRS): 4QFJ 1234 6789
  \item
    Decimal Degrees(DD): 38.8897, -77.0089
  \item
    Degrees, Minutes, Seconds(DMS): 38° 53' 23" N, 77° 00' 32" W
  \end{itemize}
\item
  You can mathematically convert between between coordinate systems
  using the \emph{conv\_units()} function in the \textbf{measurements}
  package.
\end{itemize}

\section{Spatial Data}\label{spatial-data}

Spatial data is:

\begin{itemize}
\item
  Regularly structured data.
\item
  A representation of locations and extents in digital form.
\end{itemize}

There are two main categories of spatial data:

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
  Raster - ``grid cells''

  \begin{itemize}
  \tightlist
  \item
    Cell based, like pixels in imagery
  \item
    Well suited to entities that lack clear boundaries (elevation,
    vegetation)
  \end{itemize}
\item
  Vector - ``connect the dots''

  \begin{itemize}
  \tightlist
  \item
    Points, like cities
  \item
    Lines, like roads
  \item
    Polygons, like administrative boundaries
  \item
    Well suited to entities with clear boundaries
  \end{itemize}
\end{enumerate}

\section{Packages and Data}\label{packages-and-data}

First, lets install the packages we will use in this module.

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{library}\NormalTok{(raster)}
\KeywordTok{library}\NormalTok{(ggmap)}
\KeywordTok{library}\NormalTok{(leaflet)}
\end{Highlighting}
\end{Shaded}

We will use location data from both the ``thor\_vietnam\_65\_clean.csv''
and ``takeoff.csv'' datasets.

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{takeoff <-}\StringTok{ }\KeywordTok{read.csv}\NormalTok{(}\StringTok{"takeoff.csv"}\NormalTok{, }\DataTypeTok{stringsAsFactors =} \OtherTok{FALSE}\NormalTok{)}
\NormalTok{nam65 <-}\StringTok{ }\KeywordTok{read.csv}\NormalTok{(}\StringTok{"thor_vietnam_65_clean.csv"}\NormalTok{, }\DataTypeTok{stringsAsFactors =} \OtherTok{FALSE}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\chapter{Basemaps}\label{basemaps}

Basemaps provide the basic geographic context for geospatial analysis.
The first step for creating a map for geospatial analysis is defining a
basemap that will underlay the data.

We will go over several options for creating basemaps, including
shapefiles and online maps.

\section{Shapefiles}\label{shapefiles}

Shapefiles are a popular method of representing geospatial vector data
in GIS software.

\begin{itemize}
\item
  File format was developed by ESRI (a notable GIS Software Company).
\item
  Stores data in the form of points, lines, or polygons.
\item
  Used to represent administrative boundaries (think
  country/state/county borders), roads, rivers, lakes, etc.
\end{itemize}

The \texttt{getData()} function in the \textbf{raster} package allows
you to pull geographic data for anywhere in the world.

\begin{itemize}
\item
  Pulls from an online database.
\item
  The result is a spatial polygon that can be plotted, forming a basemap
  just like a shapefile.
\end{itemize}

Let's get the Vietnam polygon from the GADM database, which is a
collection of global administrative boundaries. GADM requires you to
identify the level of detail you are interested in.

\begin{itemize}
\item
  Level 0 = country
\item
  Level 1 = first level of subdivision (such as state).
\end{itemize}

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{vt <-}\StringTok{ }\KeywordTok{getData}\NormalTok{(}\StringTok{'GADM'}\NormalTok{, }\DataTypeTok{country =} \StringTok{'Vietnam'}\NormalTok{, }\DataTypeTok{level =} \DecValTok{0}\NormalTok{)}
\KeywordTok{plot}\NormalTok{(vt)}
\end{Highlighting}
\end{Shaded}

\includegraphics{geospatial_files/figure-latex/unnamed-chunk-3-1.pdf}

Notice that the \texttt{getData()} function goes to the internet to pull
the shapefile. It is best to save it to object for easier reference
later.

The object is saved as a SpatialPolygonDataFrame.

\section{Shapefile Exercise}\label{shapefile-exercise}

Get the next level of detail for Vietnam and plot it to compare the two
levels.

\section{Uploading Shapefiles}\label{uploading-shapefiles}

If you have shapefiles in the Esri format, which is actually a
collection of multiple files stored together, you can read them into R
with the \texttt{readOGR()} function in the \textbf{rgdal} package.

You can download shapefiles at the GADM website,
\url{http://www.gadm.org/}. You can also download an ``R
SpatialPolygonsDataFrame'', which you can read into R using the
\texttt{readRDS()} function in the \textbf{rgdal} package.

\section{ggmap}\label{ggmap}

The \textbf{ggmap} package pulls base maps from online map servers like
Google Maps, OpenStreetMap, or Stamen Maps.

\begin{itemize}
\tightlist
\item
  \texttt{qmap()} function accepts a text location, used to search just
  like you do at the online map.
\end{itemize}

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{qmap}\NormalTok{(}\DataTypeTok{location =} \StringTok{"Vietnam"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\begin{figure}
\centering
\includegraphics{qmap1.png}
\caption{}
\end{figure}

\begin{itemize}
\tightlist
\item
  ``zoom'' parameter: 3 = continent, 10 = city, 21 = building (default
  is 10, max is 21)
\end{itemize}

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{qmap}\NormalTok{(}\DataTypeTok{location =} \StringTok{"Vietnam"}\NormalTok{, }\DataTypeTok{zoom =} \DecValTok{6}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\begin{figure}
\centering
\includegraphics{qmap2.png}
\caption{}
\end{figure}

\begin{itemize}
\tightlist
\item
  ``maptype'' parameter options include terrain, satellite, roadmap, and
  hybrid.
\end{itemize}

\section{Exercise}\label{exercise}

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
  Compare the 4 map types for Fort Belvoir at zoom level 13: terrain,
  satellite, roadmap, and hybrid.
\item
  Use the coordinates for Fort Belvoir, VA in the location parameter:
  38.714668, -77.143600
\end{enumerate}

\section{Map Distance}\label{map-distance}

Calculate distance:

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{mapdist}\NormalTok{(}\StringTok{"Washington DC"}\NormalTok{,}\StringTok{"Fort Belvoir, VA"}\NormalTok{, }\StringTok{"driving"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\section{Geocoding}\label{geocoding}

You may have location data that does not include latitudes and
longitudes. But plotting those points requires the lat/longs. the
\texttt{geocode()} function in \textbf{ggmaps} uses Google Maps to get
the lat/longs for text locations, just like as if you were searching in
a web browser.

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{geocode}\NormalTok{(}\StringTok{"Fort Belvoir, VA"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\begin{verbatim}
##   lon lat
## 1  NA  NA
\end{verbatim}

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{geocode}\NormalTok{(}\StringTok{"6001 Goethals Rd, Fort Belvoir, VA"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\begin{verbatim}
##         lon      lat
## 1 -77.14357 38.71472
\end{verbatim}

Try geocoding with just a place name, such as ``Disney World''.

\section{Takeoff Data}\label{takeoff-data}

Using the \texttt{geocode()} function, we created a dataset with the
coordinates of the takeoff locations (not including the ships).

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{takeoff <-}\StringTok{ }\KeywordTok{read.csv}\NormalTok{(}\StringTok{"takeoff.csv"}\NormalTok{, }\DataTypeTok{stringsAsFactors =} \OtherTok{FALSE}\NormalTok{)}
\KeywordTok{head}\NormalTok{(takeoff)}
\end{Highlighting}
\end{Shaded}

\begin{verbatim}
##        takeoff      lon      lat
## 1        KORAT 102.0978 14.97990
## 2     BIEN HOA 106.8427 10.95741
## 3      CHU LAI 108.7038 15.41441
## 4 TAN SON NHUT 106.6588 10.81846
## 5       TAKHLI 100.3273 15.28435
## 6 CAM RANH BAY 109.1702 11.89333
\end{verbatim}

\chapter{Map Layers}\label{map-layers}

Now that we have basemaps, the next step is to add data to the map.

First, let's create an object that is our basemap.

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{vnmap <-}\StringTok{ }\KeywordTok{qmap}\NormalTok{(}\DataTypeTok{location =}\StringTok{"Vietnam"}\NormalTok{, }\DataTypeTok{zoom =} \DecValTok{6}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\section{Points}\label{points}

Adding data to the basemap with the \textbf{ggmap} package uses layers,
similar to \textbf{ggplot2}.

Let's add points for the takeoff locations to the basemap. Note that
``x'' should always be mapped to the variable for longitude and ``y''
mapped to latitude.

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{vnmap }\OperatorTok{+}\StringTok{ }
\StringTok{  }\KeywordTok{geom_point}\NormalTok{(}\DataTypeTok{data =}\NormalTok{ takeoff, }\KeywordTok{aes}\NormalTok{(}\DataTypeTok{x =}\NormalTok{ lon, }\DataTypeTok{y =}\NormalTok{ lat))}
\end{Highlighting}
\end{Shaded}

\includegraphics{geospatial_files/figure-latex/unnamed-chunk-10-1.pdf}

Format the points the same way as in \textbf{ggplot2}.

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{vnmap }\OperatorTok{+}
\StringTok{  }\KeywordTok{geom_point}\NormalTok{(}\DataTypeTok{data =}\NormalTok{ takeoff, }\KeywordTok{aes}\NormalTok{(}\DataTypeTok{x =}\NormalTok{ lon, }\DataTypeTok{y =}\NormalTok{ lat), }\DataTypeTok{shape =} \DecValTok{15}\NormalTok{, }\DataTypeTok{size =} \DecValTok{2}\NormalTok{, }\DataTypeTok{colour =} \StringTok{"purple"}\NormalTok{) }
\end{Highlighting}
\end{Shaded}

\includegraphics{geospatial_files/figure-latex/unnamed-chunk-11-1.pdf}

\section{Plot Points Exercise}\label{plot-points-exercise}

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
  Subset the ``nam65'' data set for strike missions. (Hint: variable
  MFUNC\_DESC)
\item
  Plot the strike points on the basemap.
\item
  Color the strike points based on the ``MILSERVICE'' variable.
\end{enumerate}

\section{Heat Maps}\label{heat-maps}

A heat map reflects the concentration of points on the map, also thought
of as data density.

\begin{itemize}
\item
  Use the \texttt{stat\_density2d()} function to create the heat map
  layer.
\item
  \texttt{fill} mapping provides color, \texttt{alpha} mapping adjusts
  the transparency.
\item
  Remove the legend because it doesn't provide useful information:
  \texttt{show.legend\ =\ FALSE}
\end{itemize}

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{strike <-}\StringTok{ }\NormalTok{dplyr}\OperatorTok{::}\KeywordTok{filter}\NormalTok{(nam65, MFUNC_DESC}\OperatorTok{==}\StringTok{"STRIKE"}\NormalTok{)}

\NormalTok{vnmap }\OperatorTok{+}\StringTok{ }
\StringTok{  }\KeywordTok{stat_density2d}\NormalTok{(}\DataTypeTok{data =}\NormalTok{ strike, }\KeywordTok{aes}\NormalTok{(}\DataTypeTok{x =}\NormalTok{ TGTLONDDD_DDD_WGS84, }\DataTypeTok{y =}\NormalTok{ TGTLATDD_DDD_WGS84, }
                                    \DataTypeTok{fill =}\NormalTok{ ..level.., }\DataTypeTok{alpha =}\NormalTok{ ..level..), }
                 \DataTypeTok{geom =} \StringTok{"polygon"}\NormalTok{, }\DataTypeTok{show.legend =} \OtherTok{FALSE}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\includegraphics{geospatial_files/figure-latex/unnamed-chunk-12-1.pdf}

\section{Facet the Maps}\label{facet-the-maps}

You can facet maps just like plots!

\begin{itemize}
\tightlist
\item
  Use \texttt{facet\_wrap()} to organize the sub-maps with the same
  number of rows and columns.
\end{itemize}

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{vnmap }\OperatorTok{+}
\StringTok{  }\KeywordTok{stat_density2d}\NormalTok{(}\DataTypeTok{data =}\NormalTok{ strike, }\KeywordTok{aes}\NormalTok{(}\DataTypeTok{x =}\NormalTok{ TGTLONDDD_DDD_WGS84, }\DataTypeTok{y =}\NormalTok{ TGTLATDD_DDD_WGS84,}
                                    \DataTypeTok{fill =}\NormalTok{ ..level.., }\DataTypeTok{alpha =}\NormalTok{ ..level..),}
                 \DataTypeTok{geom =} \StringTok{"polygon"}\NormalTok{, }\DataTypeTok{show.legend =} \OtherTok{FALSE}\NormalTok{) }\OperatorTok{+}
\StringTok{  }\KeywordTok{facet_wrap}\NormalTok{(}\OperatorTok{~}\StringTok{ }\NormalTok{MILSERVICE)}
\end{Highlighting}
\end{Shaded}

\begin{verbatim}
## Warning: Removed 1378 rows containing non-finite values (stat_density2d).
\end{verbatim}

\includegraphics{geospatial_files/figure-latex/unnamed-chunk-13-1.pdf}

\chapter{Leaflet}\label{leaflet}

Leaflet is a library for making interactive maps. The JavaScript version
of leaflet is used by many websites and GIS specialists.

Here's a tutorial for leaflet: \url{http://rstudio.github.io/leaflet/}

\section{Leaflet Basemaps}\label{leaflet-basemaps}

Just like \textbf{ggplot2}, leaflet creates visualization in layers.

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
  Start with \texttt{leaflet()} to create a map widget.
\item
  Add a map tiles layer. The default layer is an OpenStreetMap map, with
  \texttt{addTiles()}.
\item
  Use \texttt{setView()} to center the map and set the zoom level.
\item
  Separate layers with a pipe operator \texttt{\%\textgreater{}\%}, not
  the plus sign.
\end{enumerate}

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{leaflet}\NormalTok{() }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addTiles}\NormalTok{() }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{setView}\NormalTok{(}\DataTypeTok{lng =} \DecValTok{107}\NormalTok{, }\DataTypeTok{lat =} \DecValTok{17}\NormalTok{, }\DataTypeTok{zoom =} \DecValTok{6}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

Notice that OpenStreetMap uses the local language on the map, which is
not useful for our purposes.

The \texttt{addProviderTiles()} function sets the basemap you want to
use, which are also called ``providers''. The list of providers that you
can reference with leaflet can be found
\href{https://leaflet-extras.github.io/leaflet-providers/preview/}{here}
and in this case we chose ``Esri.WorldTopoMap''.

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{leaflet}\NormalTok{() }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{setView}\NormalTok{(}\DataTypeTok{lng =} \DecValTok{107}\NormalTok{, }\DataTypeTok{lat =} \DecValTok{17}\NormalTok{, }\DataTypeTok{zoom =} \DecValTok{6}\NormalTok{) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addProviderTiles}\NormalTok{(}\StringTok{"Esri.WorldTopoMap"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\section{Add Points}\label{add-points}

Using the strike dataframe, we will add markers on the map for the
locations of the strike missions.

\begin{itemize}
\item
  Strike data:
  \texttt{strike\ \textless{}-\ dplyr::filter(nam65,\ MFUNC\_DESC=="STRIKE")}
\item
  Use \texttt{addCircleMarkers()} to add points to the base map.
\item
  Be sure to add the tilde (\textasciitilde{}) before the variable
  names.
\item
  Note: Leaflet stops plotting points after it hits an NA in the
  latitude or longitude variable, so be sure to filter out any rows with
  NAs in the geospatial variables.
\end{itemize}

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{leaflet}\NormalTok{() }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{setView}\NormalTok{(}\DataTypeTok{lng =} \DecValTok{107}\NormalTok{, }\DataTypeTok{lat =} \DecValTok{17}\NormalTok{, }\DataTypeTok{zoom =} \DecValTok{6}\NormalTok{) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addProviderTiles}\NormalTok{(}\StringTok{"Esri.WorldTopoMap"}\NormalTok{) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addCircleMarkers}\NormalTok{(}\DataTypeTok{data =}\NormalTok{ strike, }\DataTypeTok{lng=}\OperatorTok{~}\NormalTok{TGTLONDDD_DDD_WGS84, }\DataTypeTok{lat=}\OperatorTok{~}\NormalTok{TGTLATDD_DDD_WGS84, }
                   \DataTypeTok{radius =} \DecValTok{2}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\section{Add Popups}\label{add-popups}

A great feature of interactive maps is popups that provide information
when the user clicks on the marker.

\begin{itemize}
\item
  Use the ``popup'' parameter in the \texttt{addCircleMarker()} layer.
\item
  We want the popup to show the service that flew the mission.
\end{itemize}

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{leaflet}\NormalTok{() }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{setView}\NormalTok{(}\DataTypeTok{lng =} \DecValTok{107}\NormalTok{, }\DataTypeTok{lat =} \DecValTok{17}\NormalTok{, }\DataTypeTok{zoom =} \DecValTok{6}\NormalTok{) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addProviderTiles}\NormalTok{(}\StringTok{"Esri.WorldTopoMap"}\NormalTok{) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addCircleMarkers}\NormalTok{(}\DataTypeTok{data =}\NormalTok{ strike, }\DataTypeTok{lng =} \OperatorTok{~}\NormalTok{TGTLONDDD_DDD_WGS84, }\DataTypeTok{lat =} \OperatorTok{~}\NormalTok{TGTLATDD_DDD_WGS84, }
                   \DataTypeTok{radius =} \DecValTok{2}\NormalTok{, }\DataTypeTok{popup =} \OperatorTok{~}\NormalTok{strike}\OperatorTok{$}\NormalTok{MILSERVICE)}
\end{Highlighting}
\end{Shaded}

You can add multiple fields to the popup by combining them with the
\texttt{paste()} function like:

\texttt{popup\ =\ paste("Service:",\ strike\$MILSERVICE,",\ ",strike\$TAKEOFFLOCATION)}

\section{Saving Maps}\label{saving-maps}

You can save maps to use outside RStudio, ust like other visualizations,
by clicking the ``Export'' dropdown on the ``Plots'' tab.

Options: 1. Save as Image. 2. Save as PDF. 3. Copy to Clipboard.

To save a leaflet map:

\begin{itemize}
\item
  Click the ``Export'' dropdown on the ``Viewer'' tab.
\item
  Click ``Save as a Webpage''. This will create an html file for the
  leaflet map.
\item
  Name the html file. It will default to saving in your working
  directory.
\end{itemize}

\section{Leaflet Exercise}\label{leaflet-exercise}

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
  Plot the locations of strike missions by the B-57 aircraft on an Esri
  World Street Map basemap.
\item
  Popup the target type and operation supported.
\end{enumerate}

\section{Colors and Legends}\label{colors-and-legends}

\begin{itemize}
\item
  To color the points based on another variable, you need to define a
  palette for that variable and then reference it in the \texttt{color}
  parameter in \texttt{addCircleMarkers}.
\item
  Use the \texttt{addLegend()} function to add a legend for those
  colors, again referencing the defined palette.
\end{itemize}

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{svc_pal <-}\StringTok{ }\KeywordTok{colorFactor}\NormalTok{(}\KeywordTok{c}\NormalTok{(}\StringTok{"blue"}\NormalTok{,}\StringTok{"red"}\NormalTok{,}\StringTok{"orange"}\NormalTok{,}\StringTok{"green"}\NormalTok{), strike}\OperatorTok{$}\NormalTok{MILSERVICE)}

\KeywordTok{leaflet}\NormalTok{() }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{setView}\NormalTok{(}\DataTypeTok{lng =} \DecValTok{107}\NormalTok{, }\DataTypeTok{lat =} \DecValTok{17}\NormalTok{, }\DataTypeTok{zoom =} \DecValTok{6}\NormalTok{) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addProviderTiles}\NormalTok{(}\StringTok{"Esri.WorldTopoMap"}\NormalTok{) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addCircleMarkers}\NormalTok{(}\DataTypeTok{data =}\NormalTok{ strike, }\DataTypeTok{lng =} \OperatorTok{~}\NormalTok{TGTLONDDD_DDD_WGS84, }\DataTypeTok{lat =} \OperatorTok{~}\NormalTok{TGTLATDD_DDD_WGS84, }
                   \DataTypeTok{radius =} \DecValTok{2}\NormalTok{, }\DataTypeTok{popup =} \OperatorTok{~}\NormalTok{strike}\OperatorTok{$}\NormalTok{MILSERVICE,}
                   \DataTypeTok{color =} \OperatorTok{~}\KeywordTok{svc_pal}\NormalTok{(MILSERVICE)) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addLegend}\NormalTok{(}\DataTypeTok{pal =}\NormalTok{ svc_pal, }\DataTypeTok{values =}\NormalTok{ strike}\OperatorTok{$}\NormalTok{MILSERVICE)}
\end{Highlighting}
\end{Shaded}

\section{Polygon Layer}\label{polygon-layer}

Add a polygon layer with the \texttt{addPolygons()} function.

We will add the provinces of Vietnam to our map using the ``vt1''
shapefile object we created earlier.

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{vt1 <-}\StringTok{ }\KeywordTok{getData}\NormalTok{(}\StringTok{'GADM'}\NormalTok{, }\DataTypeTok{country =} \StringTok{'Vietnam'}\NormalTok{, }\DataTypeTok{level =} \DecValTok{1}\NormalTok{)}

\KeywordTok{leaflet}\NormalTok{() }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{setView}\NormalTok{(}\DataTypeTok{lng =} \DecValTok{107}\NormalTok{, }\DataTypeTok{lat =} \DecValTok{17}\NormalTok{, }\DataTypeTok{zoom =} \DecValTok{6}\NormalTok{) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addProviderTiles}\NormalTok{(}\StringTok{"Esri.WorldTopoMap"}\NormalTok{) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addPolygons}\NormalTok{(}\DataTypeTok{data =}\NormalTok{ vt1, }\DataTypeTok{fillOpacity =}\NormalTok{ .}\DecValTok{1}\NormalTok{, }\DataTypeTok{color =} \StringTok{"purple"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\section{Layer Control}\label{layer-control}

If you have multiple layers on a map, you can add the functionality to
turn them on and off with the \texttt{addLayersControl()} function. You
must identify each layer you want to control with a \texttt{group}
parameter in the layer information.

We will add the circle markers back onto the map along with the layers
control.

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{leaflet}\NormalTok{() }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{setView}\NormalTok{(}\DataTypeTok{lng =} \DecValTok{107}\NormalTok{, }\DataTypeTok{lat =} \DecValTok{17}\NormalTok{, }\DataTypeTok{zoom =} \DecValTok{6}\NormalTok{) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addProviderTiles}\NormalTok{(}\StringTok{"Esri.WorldTopoMap"}\NormalTok{) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addCircleMarkers}\NormalTok{(}\DataTypeTok{data =}\NormalTok{ strike, }\DataTypeTok{lng =} \OperatorTok{~}\NormalTok{TGTLONDDD_DDD_WGS84, }\DataTypeTok{lat =} \OperatorTok{~}\NormalTok{TGTLATDD_DDD_WGS84, }
                   \DataTypeTok{radius =} \DecValTok{2}\NormalTok{, }\DataTypeTok{popup =} \OperatorTok{~}\NormalTok{strike}\OperatorTok{$}\NormalTok{MILSERVICE, }\DataTypeTok{group =} \StringTok{"Strike"}\NormalTok{) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addPolygons}\NormalTok{(}\DataTypeTok{data =}\NormalTok{ vt1, }\DataTypeTok{fillOpacity =}\NormalTok{ .}\DecValTok{1}\NormalTok{, }\DataTypeTok{color =} \StringTok{"purple"}\NormalTok{, }\DataTypeTok{group =} \StringTok{"Province"}\NormalTok{) }\OperatorTok{%>%}
\StringTok{  }\KeywordTok{addLayersControl}\NormalTok{(}\DataTypeTok{overlayGroups =} \KeywordTok{c}\NormalTok{(}\StringTok{"Strike"}\NormalTok{,}\StringTok{"Province"}\NormalTok{))}
\end{Highlighting}
\end{Shaded}

\section{Leaflet Strikes Exercise}\label{leaflet-strikes-exercise}

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
  Create a map of strikes with layer control and different colors for
  each military service.
\item
  Hint: subset by service.
\end{enumerate}

\end{document}

ext: tex


text:
%%
%% This is file `askinclude-c13.tex',

\chapter{Chapter C}
\expandafter\let\csname filec13\endcsname=Y
\endinput
%%
%% End of file `askinclude-c13.tex'.

max_stars_repo_name: ho-tex/askinclude

max_issues_repo_name: ho-tex/askinclude

max_forks_repo_name: ho-tex/askinclude


text:
\documentclass[11pt,letterpaper,final] {article}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Packages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	\usepackage[margin=1in]{geometry}
	\usepackage{amsmath}
	\usepackage{amsfonts}
	\usepackage{fancyhdr}
	\usepackage{graphicx}
	% \usepackage{apacite}
	% \usepackage{tikz}
	% \usepackage{setspace}
	% \usepackage{multicol}
	% \usepackage[left]{lineno}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Page styling
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	%%%%%%%%%%%%%%%%%%%%
	% Headers and footers
	%%%%%%%%%%%%%%%%%%%%

	\pagestyle{fancy}
	\renewcommand{\headrulewidth}{0pt}
	\fancyhead{}
	\fancyfoot{}
	\rhead{Page \thepage}
	\lhead{Test \#12}

	%%%%%%%%%%%%%%%%%%%%
	% Graphics path
	%%%%%%%%%%%%%%%%%%%%

	\graphicspath{{./assets/}}

	%%%%%%%%%%%%%%%%%%%%
	% Frontmatter
	%%%%%%%%%%%%%%%%%%%%

	% \title{The Title}
	% \author{The Author}
	% \date{\today}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Custom definitions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	% Easy scientific notation
	\newcommand{\e}[1]{\ensuremath{\times 10^{#1}}}

	% Textual subscripts
	\newcommand{\sub}[1]{\ensuremath{_{\text{#1}}}}

	% Textual superscripts
	\newcommand{\super}[1]{\ensuremath{^{\text{#1}}}}

\begin{document}

% \linenumbers
% \maketitle

\paragraph{Question 01.} Fragile X syndrome is caused by a trinucleotide repeat expansionof the X-linked \textit{FMR1} gene, wherein an excess of 200 repeats is typically sufficient to constitute fullblown clinical disorder. This trinucleotide repeat prevents the expression of the fragile X mental retardation proteion (FMRP) for which the gene encodes (O'Donnell \& Warren, 2002). This results in elongation of dendritic spines, important for excitatory synaptic transmission and synaptic plasticity (Rudeli et al., 1985).

Following the identification of this gene and the protein for which encodes, studies in mouse models examining hippocampal synaptic plasticity suggested a connection between metabotropic glutamate receptor (mGluR) and the FX phenotype (Huber et al., 2002). Specifically, long-term depression (LTD) in the hippocampus can be triggered by activation of either postsynaptic NMDA receptors or of postsynaptic Gp1 mGluRs, with each being mechanistically distinct. In mGluR-mediated LTD, a rapid translation of mRNA in postsynaptic dendrites is required, and, unlike NMDA LTD, mGluR-LTD is not easily reversible (Oliet et al., 1997).

Subsequent experiments led to the hypothesis that Gp1 mGluR activation additionally stimulates the synthesis of FMRP which then acts as an inhibitor of further synthesis and LTD. FMRP additionally is thought to repress translation of other specific mRNAs, with a missense mutation in its RNA-binding domain inhibiting this functioning and results in severe mental retardation (Feng et al., 1997).

These and other studies in \textit{Fmr1} knockout mice led to the mGluR theory of FX, wherein it was hypothesized that overactive Gp1 mGluR signaling actively contributed to the FX phenotype, driven by the inability to synthesize functional FMRP that would otherwise negatively regulate this pathway. Further, it predicted that the administration of mGluR antagonists could dampen the protein synthesis triggered by their activation and partially rescue or even reverse the FX phenotype (Bear, Huber, \& Warren, 2004).

Indeed, clinical trials were conducted on this basis by Novartis with the drug mavoglurant. Although it proceeded to a Phase II/III open-label trial, it has been since discontinued, citing negative results and failure to meet the primary endpoint of significant improvements to abnormal behaviors among adolescents and adults with fragile X syndrome compared to placebo treatment (ClinicalTrials.gov Identifier: NCT01433354). Roche has also recently completed a Phase II study with RO4917523, although no results have yet been disclosed (ClinicalTrials.gov Identifier: NCT01015430). At this point it is not apparent whether the failures of the Novartis trial were due to an inadequacy of the mFluR theory of Fragile X (certainly preclinical data support the theory) or an inadequate dosage or outcome measures (there exists some controversy over whether tolerance develops to the drug and the scales used to measure behavioral and cognitive improvement have been panned as having poor resolution).

\paragraph{Question 02.} Given the preliminary evidence suggesting that high-intensity exercise during pregnancy produces certain brain malformation and behavioral deficits, the scientific community should begin a program of research to systematically determine any causal effects of such an exercise regiment on the child's health. Importantly, any such program of study should be attuned to the six principles of teratology (agent-specificity; species-specificity; dosage-specificity; temporal sequencing; individual differences; and interaction effects) such that a causal relationship (or lack thereof) can be definitively established. Additionally, these principles may be references in responsibly communicating the potential risk to the general public while waiting for the results of further experimentation.

Foremost, research conducted should pay mind to both the agent and species specificity of these effects: is all high-intensity exercise equally detrimental to the child's health, or are some types of exercise acceptable while others severely damaging? Likewise, do these effects hold true across species? Will animal models of this effect faithfully recapitulate the phenotype observed in humans, or are retrospective and other observational human studies the only option to study this malformation? (As it has been observed in both humans and sheep, there is at least preliminary evidence for it affecting multiple species. However, the biomechanics of quadrupeds and bipeds do significantly differ: perhaps the resulting phenotype is the same, but the causal agent differs and a bipedal animal model (i.e., a non-human primate model) would be more appropriate for experimental manipulation.)

Additionally, as it applies to both experimentation and responsible communication to the public, are concerns of dose response. That is, in communicating the potential risk to the public, it will be important to emphasize that not all exercise is bad, but that it appears, based off of initial evidence, that only high intensity exercise produces these effects and that perhaps mild to moderate intensity workouts should be adopted by expectant mothers instead until more conclusive answers emerge. In experimentation, a dose-response curve should be derived, evidencing the progression of damage to the child as a function of both intensity and frequency of exercise by the mother during pregnancy.

This leads also into interaction effects and whether a lower intensity but higher frequency exercise regiment is equally as detrimental to the child as high intensity but lower frequency exercise. It appears that the body of literature has not given any indication to whether this effect is observed; however, that the most accurate health recommendations can be made, it is neither a factor that should be overlooked in and research program. Moreover, does gestational period significantly interact with either of these factors? I.e., is there a temporal aspect to the damage? Is high intensity exercise in the first trimester beneficial, yet highly detrimental in the third?

Ultimately, these and related concerns should be definitely answered that expecting mothers are able to remain fit throughout their pregnancy without risking damage to their child. However, until such point that these questions are adequately resolved, high intensity exercise during pregnancy should, at a minimum, be discouraged, and less intense alternatives proposed.

\paragraph{Question 03.} Utilizing stem cell populations for tissue engineering offers both promises and challenges. For instance, stem cells are able to subsequently differentiate into many lineages; however, expansion of these cell populations in culture has the tendency to reduce their subsequent differentiation potential. Additionally, monitoring these cells' ongoing potential to differentiate into multiple lineages represents a costly and time-consuming process. This cost is only increased by the active maintenance of a particular cytokine milieu to direct the differentiation of these populations. Further, only a subset of the stem cell population will ultimately acquire the desired lineage-specific characteristics and this represents overall a largely uncontrolled process. Moreover, significant testing is required to evaluate the cell population.

Conversely, the use of committed cells offers a relatively easier solution in terms of isolation and maintenance of cell populations. These, unlike stem cells, can be easily grown out in culture without the loss or alteration of lineage-specific characteristics. Further, these do not require the specific and intensive monitoring that stem cells do to ensure the integrity of the specific lineage, nor must they be grown in a particular and expensive cytokine environment. There additionally exist often substantial regulatory burdens with respect to the use of stem cells that are not levied against committed cell types, facilitating translation into clinical practice. Neither does there exist the risk of abnormal or unexpected differentiation or teratoma formation \textit{in vivo} as with stem cell populations.

\paragraph{Question 04.} In arrhythmia, reentry occurs as the result of a unidirectional block caused by refractory cardiac tissue. The electrical signal will, as it propagates throughout the cardiac tissue, if timed poorly, then excite the muscle previously in its refractory period. (See Figure \ref{fig:00}.) This may ultimately result in heterogeneity of action potentials across the heart, leading to non-uniform contraction across the span of the cardiac muscle.

\begin{figure}[htp]
  \centering
    \includegraphics[width=0.45\textwidth]{reentry}
	\caption{Arrhythmia caused by reentry.}
	\label{fig:00}
\end{figure}

In the CAST trial, the investigators hypothesized that sodium channel blockers would reduce this occurrence as myocardiocytes are sodium channel gated. That is, by reducing cardiac cell excitability and slowing the flow of sodium ions into the cardiomyocyte,  the probability of hitting the calcium threshold potential will be decreased and, correspondingly, the cell will not depolarize as a function of stochastic ion movement, but only from legitimate action potentials.

However, these drugs unintentionally created a pro-arrhythmogenic environment from reentrant arrhythmias. Although, indeed, these drugs did reduce cellular excitability, they also created longer action potentials. In doing so, an action potential is then able to move through the ventricle and return to the originating cell, not while it is still in its refractory period, but when it is again able to be excited, resulting in a reentrant arrhythmia. Accordingly, this dramatically increased the risk of sudden cardiac death from an inability of the heart to any longer pump blood in a coordinated matter, having effectively decoupled the ventricle from the AV node.

\paragraph{Question 05.} Asthma begins development in childhood, often as a function of a genetically-determined sensitization risk attributable to delayed postnatal T\sub{H} cell maturation; developmental defects in T\sub{reg} cells; and an altered innate immune system (Anderson \& Cookson, 1999). Likewise, genome-wide association studies have identified evidence for asthma-related loci at genes for ``CHI3L1, IL6R, and DENND1B on chromosome 1, IL1RL1–IL18R1 on chromosome 2, PDE4D and RAD50–IL13 on chromosome 5, HLA-DQ on chromosome 6, IL33 on chromosome 9, SMAD3 on chromosome 15, ORMDL3-GSDMB on
chromosome 17, [and] IL2RB on chromosome 22'' (Martinez \& Vercelli, 2013).

In the sensitization to a new environmental protein, the incoming allergen will initially trigger pattern recognition receptors expressed by lung epithelial cells. These PRRs will then initiate the release of cytokines (primarily interleukin 1a), causing the release of additional pro-inflammatory cytokines, including granylocyte-macrophage colony-stimulating factor, IL-25, and IL-33 (Maddox \& Schwartz, 2002).

These expressed cytokines will then cause migration of dendritic cells, having sampled the antigen, to the draining lymph nodes, then presenting the allergen-derived peptide by an MHC-II molecule to a naive T cell. This cell will then differentiate into a T\sub{h}2 phenotype.

Upon re-exposure to the allergen, the T\sub{H}2 cells will be reactivated and induce production of IgE antibodies by B cells and additionally release pro-inflammatory cytokines such as IL-5, IL-9, and IL-13 that further induce eosinophilia, increase mast cell numbers in the lungs, and promote production of mucus by the lung epithelium. We further see remodeling of the airway, including thickening of the subepithelial tissue and narrowing of the airway lumen.

\paragraph{Question 06.} Among mice with the \textit{Myc} oncogene, translocation (t(8;14), t(8;22) or t(2;8)) is typically required for the onset of Burkitt lymphoma. Additionally, in leukemia and lung carcinoma, we may see its gene amplification. For tumorigenesis, however, we additionally must see downregulation of various checkpoint mechansims, including proliferative arrest, apoptosis, and cellular senescence (Gabay, Li, \& Felsher, 2014). Activation of \textit{Ras}, alternatively, induces inhibition of apoptosis through Bad, protein synthesis through mTOR, cell proliferation through GSK-3$\beta$, and cell cycle progression through FOXO. However, Ras alone is insufficient to immortalize cells, as demonstrated by Land et al. (1983). Recent work has demonstrated that c-myc has the potential to immortalize human primary prostate and breast epithelial cells, although this may be an uncommon event (Thibodeaux et al., 2009; Yaswen \& Stampfer, 2002). In any event, Myc \textit{alone} is regarded as insufficient to induce tumorigenesis and it is only in collaboration with other oncogenic events that this is observed (Murray et al. 1983; Compere et al. 1989; DeoCampo et al. 2000). Constitutive signaling of Ras, however, does allow unchecked cellular proliferation (Goodsell, 1999).

As such, activation of cellular Ras would appear to be necessary for tumorigenesis, even in animals already expressing Myc, whereas Myc activation in animals already expressing Ras only serves to amplify tumorigenesis, but is not necessary (Wang, Lisanti, \& Liao, 2011). Further, under expression of moth Ras and Myc, it seems likely that the rate of tumor production is so high as (1) constitutive Ras signaling is sufficient alone for tumorigenesis and (2) Myc in a non-linear fashion universally upregulates gene expression: that is, genes already upregulated in the absence of Myc are strongly upregulated in its presence, to a degree far greater than genes with low expression in its absence (Nie et al., 2012). As such, Myc likely serves to potentiate the effects of the already highly-expressed Ras, thus resulting in high levels of tumor production.

%%%%%%%%%%%%%%%%%%%%
%% REFERENCES
%%%%%%%%%%%%%%%%%%%%

% \clearpage
% \bibliographystyle{apacite}
% \bibliography{references}

\end{document}

max_stars_repo_name: faulconbridge/Graduate-Work

max_issues_repo_name: faulconbridge/Graduate-Work

max_forks_repo_name: faulconbridge/Graduate-Work


text:
\section{Polygonal Action in Chain Drives}

The speed of a chain\marginnote{Abstract \citep{mahalingam1958}} is subject to periodic fluctuations, even for a constant speed of the driving sprocket, due to the fact that a chain lying on a sprocket forms a polygon rather than a circle. It is shown that the dynamic loading of the chain due to this ``polygonal action'' is similar to that of a simple forced vibration where, beyond a certain critical speed, higher speeds produce lower dynamic loads.

\marginnote{notation}
\begin{description}
\item[$R$] Radius of sprocket (to center of chain pin)
\item[$T$] Number of teeth in sprocket
\item[$n$] Mean speed of sprocket (\si{\radian\per\second})
\item[$r$] Period of tooth engagement $\left(\frac{2\pi}{nT}\right)$
\item[$p$] circular frequency of tooth engagement $\left(nT\right) (\si{\radian\per\second})$
\item[$I$] Moment of inertia of driven system about axis of rotation
\item[$k$] Longitudinal stiffness of unsupported length of chain
\end{description}

The suffixes 1 and 2 refer to the driving and driven system, respectively.

When\marginnote{Introduction} the driving sprocket of a chain drive runs at constant speed, the speed of the chain itself is not constant but is subject to periodic fluctuations. This fluctuation, which is caused by the fact that the chain when wrapped on a sprocket forms a polygon rather than a circle, is known as polygonal action.

One effect of polygonal action is to produce a periodic variation in the velocity ratio of the drive, and if the frequency of this variation coincides with a resonant frequency of the system, large stresses may occur. In this respect the chain drive is similar to a Hooke's joint. Another product of the geometry of the chain drive is impact. The cause of impact is the difference in the velocities of the point on the roller and the point on the sprocket that come into contact. Polygonal action is continuous being characterized by small fluctuations, while impact represents a sharp blow of short duration. At high chain speeds the effects of impact are very complex; each impact sets up a train of travelling waves which, after reflection at the sprockets, combine with the next train and so on. The resultant ``surge'' of the chain completely predominates the dynamic effects of polygonal action. It would therefore be very difficult to separate the two factors at high speeds.

At low speeds, however, the impulsive loads are small and, owing to the longer interval between impacts, the travelling waves are damped out. Then under certain conditions the dynamic load due to polygonal action is of great importance and an analysis of this factor is made below.

Some aspects of polygonal action have been discussed in recent years. In a paper on the use of chain drives in marine diesel engines, Bremer~\cite{bremer1947} referred to the fluctuation of the chain speed and to minimize it he recommended sprockets of at least about 30 teeth. The variation of the angular speed of the driven sprocket was studied by Morrison~\cite{morrison1952}. In his analysis the drive was considered as being equivalent to a series of four-bar linkages, each acting for a period equal to the period of tooth engagement.

The analysis given below deals with the dynamic load in the chain strand, taking into consideration the elasticity of the chain and the moment of inertia of the driven system. It is shown that the effect of polygonal action is similar to that of a forced vibration.

In\marginnote{Analysis} the following analysis it will be assumed that the driving sprocket runs at a constant speed of $n_1$ \si{\radian\per\second}. The reference axes, taken at $O_1$, will be parallel and perpendicular to the direct common tangent to the pitch circles of the sprockets. The change of slope of the chain will be neglected.

In \cref{fig-poly-1}, $A_1$ and $A_2$ represent the pins that are articulating and therefore $O_1A_1A_2O_2$ represents the equivalent four-bar mechanism. Angles $B_1O_1C_1$ and $B_2O_2C_2$ represent the range of operation of the linkage. The exact formula for $O_2$, assuming $A_1A_2$ to be rigid, as given in \ref{eq-poly-3} is extremely cumbersome and an approximate value may be obtained as follows:

\begin{equation}
  \text{Speed of Chain} \simeq n_1R_1\sin\theta_1
\end{equation}

\noindent{} Hence,

\begin{equation}
  \dot{\theta_2} \simeq n_1\frac{R_1\sin\theta_1}{R_2\sin\theta_2}
\end{equation}

In practice, this method usually gives a high degree of accuracy because the angles $B_1O_1C_1$ and $B_2O_2C_2$ are small and the change in the slope of $A_1A_2$ is negligible.

\begin{figure}[th!]
  \centering
  \includegraphics[width=0.9\textwidth]{A2_polygonal_action/fig1.png}
  \caption{equivalent four-bar linkage in chain drive}
  \label{fig-poly-1}
\end{figure}

When two equal sprockets are used at a distance apart equal to an integral multiple of the pitch, then $R_1\sin\theta_1$ is always equal to $R_2\sin\theta_2$,and $\dot{\theta}_2$ is constant. In all other cases $\dot{\theta}_2$ will be subject to small fluctuations.

The elasticity of the chain will now be considered. Since each four-bar linkage operates for a period $\tau=\frac{2\pi}{n_1T_1}=\frac{2\pi}{n_2T_2}$ the quantity $R_1\sin\theta_1$ is a function of period $\tau$ and can therefore be expressed as a Fourier series. If we include only the fundamental harmonic term of the series, then it may be shown that

\begin{equation}
    R_1\sin\theta_1 \simeq R_1\frac{T_1}{\pi}\sin\frac{\pi}{T_1}\left[1-\frac{2}{T_1^2-1}\cos pt\right]
    \label{eq-poly-2}
\end{equation}

where $p=n_1T_1=n_2T_2$, and $t$ represents time.

In most power transmitting sprockets the number of teeth is never less than about 15 and therefore the coefficient $\frac{2}{T_1^2-1}$ may be regarded as a small quantity.

Equation~\ref{eq-poly-2} may be written in a simpler form as:

\begin{equation}
  R_1\sin\theta_1 \simeq a_0 + a_1\cos pt
\end{equation}

The speed of $A_1$ is then given by:

\begin{equation}
  -\dot{x}_1 \simeq n_1\left(a_0+ a_1\cos pt\right)
\end{equation}

and by integration:

\begin{equation}
  -x_1 \simeq n_1\left(a_0t+ \frac{a_1}{p}\sin pt\right) + A
  \label{eq-poly-3}
\end{equation}

where $A$ is the constant of integration. In a similar manner it may be shown that:

\begin{equation}
  R_2\sin\theta_2 \simeq Na_0+\frac{a_1}{N}\cos (pt-\alpha)
  \label{eq-poly-4}
\end{equation}

where:

\begin{description}
\item[$\alpha$] a ``phase angle'' corresponding to the fractional pitch in direct common tangent to the pithc circles
\item[$N$] speed ratio $\frac{T_2}{T_1}=\frac{R_2}{R_1}\frac{\frac{T_2}{\pi}\sin\frac{\pi}{T_2}}{\frac{T_1}{\pi}\sin\frac{\pi}{T_1}}$
\end{description}

Equation~\ref{eq-poly-4} has been derived on the assumption that the speed of the driven sprocket is constant. The speed is in fact subject to small fluctuations but it may be shown that the error involved in Equation~\ref{eq-poly-4} is negligible.

Equation~\ref{eq-poly-4} may be written

\begin{equation}
  R_2\sin\theta_2\simeq Na_0+\frac{b_1}{N}\cos pt + \frac{c_1}{N}\sin pt
  \label{eq-poly-5}
\end{equation}

where:

\begin{itemize}
\item $b_1=a_1\cos\alpha$
\item $c_1=a_1\sin\alpha$
\end{itemize}

Let the speed of $A_2$ be given by:

\begin{equation}
  -\dot{x}_2 \simeq \frac{n_1}{N}\left[Na_0+\frac{l_1}{N}\cos pt +\frac{m_1}{N} \sin pt\right]
  \label{eq-poly-6}
\end{equation}

where $l_1$, $m_1$ are constant to be determined.

Integrating and substituting boundary conditions

\begin{equation}
  -\dot{x}_2 \simeq \frac{n_1}{N}\left[Na_0t+\frac{l_1}{pN}\sin pt +\frac{m_1}{pN} \cos pt\right] + A + l
\end{equation}

Now $\dot{\theta}_2 \simeq \frac{-\dot{x}_2}{R_2\sin\theta_2}$ and substituting from \ref{eq-poly-5} and \ref{eq-poly-6} and noting that $b_1$ and $c_1$ are small quantities we get:

\begin{equation}
  \dot{\theta}_2 \simeq \frac{n_1}{N}\left[ 1 + \frac{l_1-b_1}{N^2a_0}\cos pt + \frac{m_1-c_1}{N^2a_0} \sin pt \right]
\end{equation}

This gives

\begin{equation}
  \ddot{\theta}_2 = \frac{N1p}{N^3a_0}\left[(m_1-c_1)\cos pt - (l_1-b_1)\sin pt \right]
\end{equation}

For the oscillation of the driven system about its axis of rotation, the equation of motion is:

\begin{equation}
  I\ddot{\theta}_2 = k(x_1+l-x_2)R_2\sin\theta_2=0
\end{equation}

where $I=$ moment of inertia of driven system about axis of rotation and $k=$ longitudinal stiffness of chain.

Substituting for $\ddot{\theta}_2$, $x_2$, $x_1$ and $R_2\sin\theta_2$ we get

\begin{equation}
  \left[p^2(m_1-c_1)-\omega^2m_1 \right]\cos pt + \left[\omega^2(l_1-a_1N^2)-p^2(l_1-b_1) \right]\sin pt = 0
\end{equation}

where $\omega = \left(\frac{kN^2a_0^2}{I}\right)^\frac{1}{2}$

Since this equation is to be satisfied for all $t$, we get

\begin{equation}
  m_1 = \frac{c_1}{1-\frac{\omega^2}{p^2}}
\end{equation}

and

\begin{equation}
  l_1=\frac{b_1-a_1\frac{N^2\omega^2}{p^2}}{1-\frac{\omega^2}{p^2}}
\end{equation}

\begin{equation}
\text{Dynamic load in chain} =k(x_1+l-x_2)
\end{equation}

\begin{equation}
=\frac{k}{T_1}\left[\left(\frac{l_1}{N^2}-a_1\right)\sin pt - \frac{m_1}{N^2}\cos pt\right]
\end{equation}

Substituting for $l_1$ and $m_1$ the maximum dynamic load is given by

\begin{equation}
  P=\frac{k}{T_1}\left[\left(\frac{b_1}{N^2}-a_1\right)^2+\left(\frac{c_1}{N^2}\right)^2\right]^\frac{1}{2} \frac{1}{1-\frac{\omega^2}{p^2}}
\end{equation}

This shows that the dynamic effect of polygonal action is similar to that of a forced vibration and that large forces may develop when $p$, the circular frequency of tooth engagement, is equal to $\omega$, the natural circular frequency of the system.

Putting

\begin{itemize}
\item $b_1=a_1\cos\alpha$
\item $c_1=a_1\sin\alpha$
\end{itemize}

we get

\begin{equation}
  \begin{split}
  P &\propto \frac{a_1^2}{N^4}\left[\left(\cos\alpha-N^2\right)^2 + \sin^2\alpha\right] \\
  &\propto \frac{a_1^2}{N^4}\left(1-2N^2\cos\alpha+N^4\right)
  \end{split}
\end{equation}

This shows that for a given speed ratio $N$, the dynamic load $P$ is

\begin{itemize}
\item[i] a minimum when $\alpha=0$, that is, integral number of pitches in the direct common tangent.
\item[ii] a maximum when $\alpha=\pi$, that is, an odd number of half pitches in the direct common tangent.
\end{itemize}

As can be expected, the dynamic load is zero when $N = 1$ and $\alpha = 0$, that is, equal sprockets at a distance apart equal to an integral multiple of the pitch.

It is also possible for resonance to occur at half the critical speed, being excited by the second harmonic, but the dynamic load due to this is likely to be small.

max_stars_repo_name: JamesGopsill/ShaftDesignCourseNotes

max_issues_repo_name: JamesGopsill/ShaftDesignCourseNotes

max_forks_repo_name: JamesGopsill/ShaftDesignCourseNotes