Commit e8ba1b80 authored by Alex Nunes's avatar Alex Nunes

Added to analysis notebook

parent b4af4280
......@@ -158,13 +158,22 @@
"nr_detections_with_filter <- glatos::false_detections(non_release_detections, tf = 3600)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br/>\n",
"The result of ``fals_detections()`` adds a ``passed_filter`` column to the table. We can use this column to get only the detections that passed the filter."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"filtered_detections <- nr_detections_with_filter %>% filter(passed_filter != FALSE)"
"filtered_detections <- nr_detections_with_filter %>% filter(passed_filter != FALSE)\n",
"filtered_detections"
]
}
],
......
......@@ -4,7 +4,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Data Analysis Using GLATOS"
"# Data Analysis Using GLATOS\n",
"\n",
"__Data analysis__ is a process of inspecting, cleansing, transforming, and modeling data with the goal of discovering useful information, informing conclusions, and supporting decision-making *(https://en.wikipedia.org/wiki/Data_analysis)*.\n",
"\n",
"Basically, the point is to turn data into information and information into knowledge. There are many ways to look at and compare dependent and independent variables, find relations, and even create models and predict behaviours. But, we are only going to focus on analyzing time and location data in the simplest way.\n",
"\n",
"First, clean and filter the data:"
]
},
{
......@@ -22,6 +28,16 @@
"filtered_detections <- detections %>% filter(passed_filter != FALSE)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"detection_events <- glatos::detection_events(filtered_detections)\n",
"detection_events"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -41,7 +57,77 @@
"metadata": {},
"outputs": [],
"source": [
"library(lubridate)"
"library(lubridate)\n",
"detection_events <- detection_events %>% mutate(detection_interval = lubridate::interval(first_detection, last_detection))\n",
"\n",
"# detection_events"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now that we have an interval column, we can go row by row and look at each location to figure out if more than one animal was seen at a station. This is the beginning of a cohort analysis."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
" individual detection event\n",
"for(event in detection_events$event) {\n",
" \n",
" detection_events$overlaps_with[event] = paste( # We use paste to create a string of other events\n",
" which(detection_events$location == detection_events$location[event] & # Make sure that the location is the same\n",
" detection_events$event != event & # Make sure the event is not the same\n",
" lubridate::int_overlaps(detection_events$detection_interval[event], detection_events$detection_interval) # We can use lubridate's int_overlaps function to find the overlapping events\n",
" ), \n",
" collapse=\",\")\n",
"}\n",
"detection_events"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can then filter based on whether or not the ``overlaps_with`` string is empty"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"detection_events %>% select(-one_of(\"detection_interval\")) %>% filter(detection_events$overlaps_with != '')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Summarise"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"detection_events %>% group_by(location) %>% summarise(detection_count = sum(num_detections),\n",
" num_unique_tags = n_distinct(individual),\n",
" total_residence_time_in_seconds = sum(detection_interval))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plotting"
]
},
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment