-
Notifications
You must be signed in to change notification settings - Fork 20
G Andreasen submission #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
midwesternmouse
wants to merge
1
commit into
qtran4:main
Choose a base branch
from
midwesternmouse:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # BIOS 30318 Biocomputing -- Plotting data | ||
| # G Andreasen | ||
| # 11 18 2022 | ||
|
|
||
| library(ggplot2) | ||
| library(cowplot) | ||
|
|
||
| setwd("~/Documents/Courses/Biocomputing_BIOS_60318/Tutorials/Exercise09") | ||
|
|
||
| # Data from Bartel et al. 2005 "Mammal abundance indices in the northern | ||
| # portion of the Great Basin" | ||
| # <https://www.esapubs.org/archive/ecol/E086/172/default.htm#data> | ||
| # Indices of abundance of selected mammals were obtained for two study areas | ||
| # within the Great Basin: the Idaho National Engineering and Environmental | ||
| # Laboratory, Idaho, (INEEL) and Curlew Valley, (CV) Utah, USA. Data collection | ||
| # occurred biannually 1962–1993, with varying durations among species and sites. | ||
| mammals <- read.table(file = "Mammal_abundance_indices.txt", | ||
| sep = '\t', header = TRUE) | ||
|
|
||
| # "-999 denotes no data collected given appropriate season" | ||
| # Let's replace -999 with 'NA' | ||
| mammals[mammals == -999] <- NA | ||
|
|
||
| # Problem 1: scatter plot w/ trend line | ||
| # Let's assume a correlation between the number of coyotes (Canis) in the CV | ||
| # region and the number of rabbits (Lepus) in the CV region. | ||
| ggplot(data = mammals, | ||
| aes(x = CV.Canis, y = CV.Lepus, color = Season)) + | ||
| geom_point() + | ||
| xlab("No. of coyotes in CV") + | ||
| ylab("No. of rabbits in CV") + | ||
| scale_color_manual(values = c("orange", "yellowgreen")) + | ||
| stat_smooth(method="lm") + | ||
| theme_classic() | ||
|
|
||
|
|
||
| # Problem 2: data.txt plots -- barplot and scatter | ||
| data <- read.delim(file = "data.txt", sep = ',', header = TRUE) | ||
|
|
||
| # Calculate the means | ||
| data_means <- aggregate(data[, 2], list(data$region), mean) | ||
| # Rename the columns | ||
| colnames(data_means) <- c("region", "observation_mean") | ||
|
|
||
| # Barplot time | ||
| ggplot(data = data_means, | ||
| aes(x = region, y = observation_mean, fill = region)) + | ||
| geom_bar(stat = "identity") + | ||
| xlab("Region") + | ||
| ylab("Mean observation") | ||
|
|
||
| # Scatterplot time | ||
| ggplot(data = data, | ||
| aes(x = region, y = observations, color = region)) + | ||
| geom_point() + | ||
| geom_jitter(width = 0.25) + | ||
| xlab("Region") + | ||
| ylab("Observations") | ||
|
|
||
| # Do the bar and scatter plots tell you different stories? Why? | ||
| # They do. In it's nature, the bar plot can only show you one value - in our | ||
| # case, the mean - unless you add error bars. While this is informative, it | ||
| # does not depict the breadth and variability in the data -- unlike a | ||
| # scatterplot. The bar plot minimizes the data to one value, while the | ||
| # scatterplot shows the variability in the data. | ||
| # When looking at the barplot, there seems to be very little difference in the | ||
| # data. However, looking at the scatterplot, we can see the huge distribution | ||
| # of data points in east compared to north, as well as the weird split in | ||
| # observations in the south region. It's also easier to see the lack of | ||
| # natural distribution in the data points in the west region. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| Year Season INEEL Canis INEEL Lepus INEEL Rabbits INEEL Peromyscus INEEL Perognathus INEEL Dipodomys ordii INEEL Tamias INEEL Spermophilus CV Canis CV Lepus CV Peromyscus CV Reithrodontomys CV Onychomys CV Perognathus CV Dipodomys ordii CV Dipodomys microps CV Tamias CV Ammospermophilus | ||
| 1962 Fall -999 -999 -999 -999 -999 -999 -999 -999 -999 9.7 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1963 Spring -999 -999 -999 -999 -999 -999 -999 -999 -999 7.0 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1963 Fall -999 -999 -999 -999 -999 -999 -999 -999 7.5 23.4 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1964 Spring -999 -999 -999 -999 -999 -999 -999 -999 -999 9.0 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1964 Fall -999 -999 -999 -999 -999 -999 -999 -999 6.4 16.8 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1965 Spring -999 -999 -999 -999 -999 -999 -999 -999 -999 9.3 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1965 Fall -999 -999 -999 -999 -999 -999 -999 -999 6.3 12.0 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1966 Spring -999 -999 -999 -999 -999 -999 -999 -999 -999 6.4 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1966 Fall -999 -999 -999 -999 -999 -999 -999 -999 4.3 9.8 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1967 Spring -999 -999 -999 -999 -999 -999 -999 -999 -999 3.4 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1967 Fall -999 -999 -999 -999 -999 -999 -999 -999 2.1 4.3 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1968 Spring -999 -999 -999 -999 -999 -999 -999 -999 -999 4.8 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1968 Fall -999 -999 -999 -999 -999 -999 -999 -999 1.4 25.9 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1969 Spring -999 -999 -999 -999 -999 -999 -999 -999 -999 40.1 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1969 Fall -999 -999 -999 -999 -999 -999 -999 -999 2.4 55.0 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1970 Spring -999 -999 -999 -999 -999 -999 -999 -999 -999 36.1 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1970 Fall -999 -999 -999 -999 -999 -999 -999 -999 5.2 85.0 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1971 Spring -999 -999 -999 -999 -999 -999 -999 -999 -999 53.2 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1971 Fall -999 -999 -999 -999 -999 -999 -999 -999 8.2 79.4 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1972 Spring -999 -999 -999 -999 -999 -999 -999 -999 -999 35.9 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1972 Fall -999 -999 -999 -999 -999 -999 -999 -999 15.1 31.6 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1973 Spring -999 -999 -999 -999 -999 -999 -999 -999 -999 6.6 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1973 Fall -999 -999 -999 -999 -999 -999 -999 -999 6.0 3.7 9.0 0.1 0.0 4.7 1.3 0.8 1.3 0.2 | ||
| 1974 Spring -999 -999 -999 -999 -999 -999 -999 -999 2.7 1.9 12.5 0.0 0.2 4.1 2.1 0.2 0.2 0.3 | ||
| 1974 Fall -999 -999 -999 -999 -999 -999 -999 -999 5.5 12.9 15.4 0.0 0.0 2.8 5.0 1.4 2.2 0.6 | ||
| 1975 Spring 7.5 0.1 -999 4.0 0.3 1.8 2.2 1.4 4.7 0.5 6.4 0.1 0.1 4.8 0.6 0.9 0.6 0.0 | ||
| 1975 Fall 26.2 0.1 -999 4.5 0.5 1.5 1.9 0.0 6.5 3.4 2.7 0.0 0.1 1.6 1.0 0.4 0.7 0.0 | ||
| 1976 Spring 13.2 0.0 -999 12.3 0.7 1.1 2.3 1.7 4.6 0.8 23.5 0.0 0.1 2.9 0.6 0.6 0.8 0.1 | ||
| 1976 Fall 50.1 0.1 -999 14.3 0.4 2.3 2.9 0.0 13.1 13.5 17.1 0.2 0.2 0.8 1.2 0.9 1.5 0.7 | ||
| 1977 Spring 10.1 0.0 -999 11.6 0.8 1.6 2.5 1.7 0.9 3.5 11.2 1.1 0.3 3.6 2.8 1.0 1.1 0.6 | ||
| 1977 Fall 44.6 7.0 -999 7.5 0.1 0.7 1.1 0.0 6.5 19.8 3.0 0.1 0.2 0.1 0.1 0.2 0.2 0.4 | ||
| 1978 Spring 20.6 12.0 -999 8.1 0.3 0.8 0.9 0.6 2.7 11.9 24.1 1.0 0.4 0.7 1.0 0.4 0.3 0.2 | ||
| 1978 Fall 33.9 11.2 -999 11.9 0.1 0.8 1.9 0.0 9.7 59.9 13.4 0.3 0.8 0.2 2.0 1.1 1.2 1.4 | ||
| 1979 Spring 15.3 43.0 19.0 -999 -999 -999 -999 -999 6.4 41.0 10.8 0.0 0.2 0.8 1.8 0.7 0.7 0.8 | ||
| 1979 Fall 61.5 37.6 28.0 -999 -999 -999 -999 -999 15.9 93.2 3.2 0.0 0.3 0.0 0.8 0.5 0.5 0.4 | ||
| 1980 Spring 34.7 151.0 25.0 -999 -999 -999 -999 -999 4.4 60.4 9.5 0.2 0.1 0.3 1.1 0.4 0.2 0.1 | ||
| 1980 Fall 59.8 119.5 38.0 30.1 0.1 1.4 1.8 0.0 29.0 163.8 8.7 0.1 0.2 0.1 0.4 0.4 0.2 0.8 | ||
| 1981 Spring 55.6 422.0 18.0 43.0 0.5 1.9 3.9 3.3 16.3 124.4 21.4 1.9 0.1 0.6 0.7 0.2 0.7 0.2 | ||
| 1981 Fall 101.3 102.4 58.0 32.1 0.2 7.3 5.7 0.0 27.7 160.0 20.7 1.6 0.5 0.2 1.5 0.6 0.6 0.4 | ||
| 1982 Spring 62.9 242.0 6.0 6.6 0.5 0.4 3.3 3.1 4.7 85.7 3.0 0.0 0.0 0.2 0.0 0.1 0.7 0.0 | ||
| 1982 Fall 128.9 102.9 23.0 12.7 0.2 0.7 2.2 0.0 20.3 56.2 6.0 0.1 0.1 0.5 0.0 0.2 0.4 0.0 | ||
| 1983 Spring 68.8 73.0 5.0 -999 -999 -999 -999 -999 3.3 44.1 9.0 0.2 0.0 0.5 0.1 0.1 0.5 0.0 | ||
| 1983 Fall 137.0 35.0 3.0 24.1 0.5 2.4 2.1 0.0 28.3 37.0 36.7 0.3 0.1 0.4 0.1 0.1 1.1 0.0 | ||
| 1984 Spring 65.3 0.0 0.0 -999 -999 -999 -999 -999 8.9 5.0 5.9 0.0 0.0 0.2 0.1 0.0 0.6 0.0 | ||
| 1984 Fall 54.9 0.1 1.0 11.5 0.1 2.0 1.4 0.0 19.3 0.4 12.3 0.0 0.0 0.8 0.0 0.0 0.6 0.0 | ||
| 1985 Spring 47.0 0.0 0.0 9.3 0.4 1.8 1.3 1.4 8.5 1.8 14.1 0.5 0.0 1.8 0.1 0.0 0.7 0.0 | ||
| 1985 Fall 37.9 0.0 0.0 18.8 0.1 2.2 1.7 0.0 22.7 2.2 12.3 0.1 0.0 0.2 0.5 0.0 0.6 0.0 | ||
| 1986 Spring 31.3 0.0 0.0 20.4 0.1 1.7 2.6 4.4 13.0 2.2 10.4 0.0 0.0 2.1 0.3 0.0 0.4 0.0 | ||
| 1986 Fall 81.1 0.0 0.0 19.4 0.0 1.8 1.6 0.0 15.1 1.4 12.2 0.0 0.0 0.6 0.2 0.0 1.3 0.0 | ||
| 1987 Spring -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1987 Fall -999 -999 -999 -999 -999 -999 -999 -999 17.5 -999 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1988 Spring -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1988 Fall -999 -999 -999 -999 -999 -999 -999 -999 26.3 -999 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1989 Spring -999 -999 -999 -999 -999 -999 -999 -999 10.9 14.1 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1989 Fall -999 -999 -999 -999 -999 -999 -999 -999 20.1 31.7 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1990 Spring -999 -999 -999 -999 -999 -999 -999 -999 5.3 36.5 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1990 Fall -999 -999 -999 -999 -999 -999 -999 -999 17.3 92.3 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1991 Spring -999 -999 -999 -999 -999 -999 -999 -999 7.9 60.3 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1991 Fall -999 -999 -999 -999 -999 -999 -999 -999 22.3 103.6 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1992 Spring -999 -999 -999 -999 -999 -999 -999 -999 6.7 75.7 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1992 Fall -999 -999 -999 -999 -999 -999 -999 -999 16.3 112.7 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1993 Spring -999 -999 -999 -999 -999 -999 -999 -999 23.1 29.4 -999 -999 -999 -999 -999 -999 -999 -999 | ||
| 1993 Fall -999 -999 -999 -999 -999 -999 -999 -999 8.6 28.5 -999 -999 -999 -999 -999 -999 -999 -999 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can also use stat_summary as shown in the lecture