Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/emkcosta/KillifishAutomaticFeederPaper
08 June 2025, 20:12:30 UTC
  • Code
  • Branches (2)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/add-license-1
    • refs/heads/main
    • f3f0c6c0be9fcd0f5c8ca9e674074d61d659f5aa
    No releases to show
  • 5ef8760
  • /
  • Fig3_SuppFig3
  • /
  • Fig3_AMfix_221013_JC.R
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge Iframe embedding
swh:1:cnt:0c635454af752bb55425c7ac83a863c7f648cbae
origin badgedirectory badge Iframe embedding
swh:1:dir:6329462a1e73e4a679dc440e8efc11c7ed489f47
origin badgerevision badge
swh:1:rev:f3f0c6c0be9fcd0f5c8ca9e674074d61d659f5aa
origin badgesnapshot badge
swh:1:snp:a9f2e10f0b2ec00bc74865a9a1af5fd0004baa95
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: f3f0c6c0be9fcd0f5c8ca9e674074d61d659f5aa authored by Emma on 24 October 2022, 20:31:33 UTC
Update README.md
Tip revision: f3f0c6c
Fig3_AMfix_221013_JC.R
# Growth rate for AL vs DR
library(ggplot2)
set.seed(1234)

###################################################################
# Functions
###################################################################
# dataset, xaxis, yaxis, colorgroup

# "global" variables
gcol = c(AL = "#0072B5", DR = "#EF932F", OE = "#010101")
pd <- position_jitter(width = 0.1)

# define boxplot function
boxit <- function(df, xa, ya, color, filename, xlabel, ylabel) {
	# getting pval
	pval = wilcox.test(df[,ya] ~ df[,xa])
	
	# real plot, fixed extra point with "outlier.shape = NA" argument
	p = ggplot(df, aes_string(x = xa, y = ya, color = color)) + 
	  geom_boxplot(width=0.5, outlier.shape = NA)  +
	  geom_point(position = pd) + 
	  theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank() , text=element_text(size=16,family="Helvetica", colour = "#010101"), legend.position ="none", axis.text.x = element_text(colour = "#010101"), axis.text.y = element_text(colour = "#010101")) + 
	  ggtitle(sprintf("p-value = %06f", pval$p.value)) +
	  ylab(ylabel)+ xlab(xlabel) +
	  scale_color_manual(values=gcol)

	print(p)

# filename
saveout = paste("/Users/jingxun/Dropbox/KillifishFeederPaper_AndrewMcKay/Revision/Code/GitHub/Fig3/Output/", filename, sep = "")
ggsave(saveout, p)
}


# define getstat function
getstats <- function(dataset, cond1, cond2, stat1) {
x1 = dim(dataset[dataset$FeedingScheme == cond1, ])[1]
print(paste("Number", cond1, ":", x1 ))
y1 = dim(dataset[dataset$FeedingScheme == cond2, ])[1]
print(paste("Number", cond2, ":", y1 ))
	x2 = mean(dataset[dataset$FeedingScheme == cond1, c(stat1)])
print(paste("Mean", cond1, ":", x2 ))
y2 = mean(dataset[dataset$FeedingScheme == cond2, c(stat1)])
print(paste("Mean", cond2, ":", y2 ))
x3 =  median(dataset[dataset$FeedingScheme == cond1, c(stat1)])
print(paste("Median", cond1, ":", x3 ))
y3 = median(dataset[dataset$FeedingScheme == cond2, c(stat1)])
print(paste("Median", cond2, ":", y3 ))
}


###################################################################
# Load growth rate data for DR vs AL
###################################################################

setwd('/Users/jingxun/Dropbox/KillifishFeederPaper_AndrewMcKay/Revision/Code/GitHub/Fig3/Input/')
data = read.table("fig3growthrate_DR.csv", sep = ',', header = TRUE)

data$FeedingScheme = as.factor(data$FeedingScheme)
data$FeedingScheme = factor(data$FeedingScheme, levels = c("AL", "DR"))

# split out males and females
dfm = data[data$Sex == "m", ]
dff = data[data$Sex == "f",]

# select only fish that were observed (1 = observed)
dfm_1 = dfm[dfm$Observed == 1, ]
dff_1 = dff[dff$Observed == 1, ]

# select only fish with lifespan shorter than 120 days (4 months)
dfm_120 = dfm_1[dfm_1$Lifespan_days <= 120, ]
dff_120 = dff_1[dff_1$Lifespan_days <= 120, ]


###################################################################
# Plot all fish growth rates first DR vs AL
###################################################################

getstats(data, "AL", "DR", "GrowthRate")

boxit(data, "FeedingScheme", "GrowthRate", "FeedingScheme", "all_fishsizes_DR.pdf", "Feeding Scheme", "Growth Rate (cm/week)")

###################################################################
# Female fish only DR vs AL
###################################################################

getstats(dff_120, "AL", "DR", "GrowthRate")

boxit(dff_120, "FeedingScheme", "GrowthRate", "FeedingScheme", "female_fishsizes_DR.pdf", "Feeding Scheme", "Growth Rate (cm/week)")


###################################################################
# Male fish only DR vs AL
###################################################################

getstats(dfm_120, "AL", "DR", "GrowthRate")

boxit(dfm_120, "FeedingScheme", "GrowthRate", "FeedingScheme", "male_fishsizes_DR.pdf", "Feeding Scheme", "Growth Rate (cm/week)")

###################################################################
# Growth Rate for OE vs AL
###################################################################

data_OE = read.table("fig3growthrate_OE.csv", sep = ',', header = TRUE, stringsAsFactors = FALSE)

data_OE = data[data$FeedingScheme != "manual",]

data_OE$FeedingScheme[data_OE$FeedingScheme == "2hr"] = "AL"
data_OE$FeedingScheme[data_OE$FeedingScheme == "1hr"] = "OE"

data_OE$FeedingScheme = as.factor(data_OE$FeedingScheme)

# split out males and females
dfm_OE = data_OE[data_OE$Sex == "male", ]
dff_OE = data_OE[data_OE$Sex == "female",]

# select only fish that were observed (1 = observed)
dfm_1_OE = dfm_OE[dfm_OE$Observed == 1, ]
dff_1_OE = dff_OE[dff_OE$Observed == 1, ]

# select only fish with lifespan shorter than 120 days (4 months)
dfm_120_OE = dfm_1_OE[dfm_1_OE$Lifespan_days <= 120, ]
dff_120_OE = dff_1_OE[dff_1_OE$Lifespan_days <= 120, ]

###################################################################
# Plot all fish growth rates first OE vs AL
###################################################################

#Getting stats
getstats(data_OE, "AL", "OE", "GrowthRate")

boxit(data_OE, "FeedingScheme", "GrowthRate", "FeedingScheme", "all_fishsizes_OE.pdf", "Feeding Scheme", "Growth Rate (cm/week)")

###################################################################
# Female fish only
###################################################################

getstats(dff_120_OE, "AL", "OE", "GrowthRate")

boxit(dff_120_OE, "FeedingScheme", "GrowthRate", "FeedingScheme", "female_fishsizes_OE.pdf", "Feeding Scheme", "Growth Rate (cm/week)")

###################################################################
# Male fish only
###################################################################

getstats(dfm_120_OE, "AL", "OE", "GrowthRate")

boxit(dfm_120_OE, "FeedingScheme", "GrowthRate", "FeedingScheme", "male_fishsizes_OE.pdf", "Feeding Scheme", "Growth Rate (cm/week)")

######################################################################








######################################################################
# Load fertility
######################################################################

df = read.table("fig3_DRfertility.csv", sep = ',', header = TRUE,stringsAsFactors = FALSE)

# set date uncrossed to factor, then order levels
df$Uncrossed = as.factor(df$Uncrossed) 

# swap "7times" for "AL" to match with other data (and color scheme)
df$FeedingScheme[df$FeedingScheme == "7times"] = "AL"

######################################################################
# LiveEmbryos first, DR vs AL
######################################################################

#Getting stats

df[df$Crossed == "6/29/20", c("Pair", "FeedingScheme")]

getstats(df, "AL", "DR", "LiveEmbryosHarvestedDay0")

boxit(df, "FeedingScheme", "LiveEmbryosHarvestedDay0", "FeedingScheme", "DRfertilityLiveEmbryos.pdf", "Feeding Scheme", "Fertility (Fertilized Embryos per mating)")

######################################################################
# Total Embryos, DR vs AL
######################################################################

getstats(df, "AL", "DR", "TotalEmbryosHarvested")

boxit(df, "FeedingScheme", "TotalEmbryosHarvested", "FeedingScheme", "DRfertilityTotalEmbryos.pdf", "Feeding Scheme", "Fertility (Total Embryos per mating)")


######################################################################
# Load fertility data and plot
######################################################################

df = read.table("fig3_OEfertility.csv", sep = ',', header = TRUE, stringsAsFactors = FALSE)

# subset to automatic feeding only
df = df[df$FeedingScheme != "manual", ]

df$FeedingScheme[df$FeedingScheme == "7times/AL"] = "AL"
df$FeedingScheme[df$FeedingScheme == "12times/OF"] = "OE"


######################################################################
# Fertilized embryos first
######################################################################

df[df$Crossed == "7/22/19", c("Pair", "FeedingScheme")]

getstats(df, "AL", "OE", "LiveEmbryosHarvestedDay0")

boxit(df, "FeedingScheme", "LiveEmbryosHarvestedDay0", "FeedingScheme", "fertilityOE_LiveEmbryos.pdf", "Feeding Scheme", "Fertility (Fertilized Embryos per mating)")

######################################################################
# Total embryos
######################################################################

getstats(df, "AL", "OE", "TotalEmbryosHarvested")

boxit(df, "FeedingScheme", "TotalEmbryosHarvested", "FeedingScheme", "fertilityOE_TotalEmbryos.pdf", "Feeding Scheme", "Fertility (Total Embryos per mating)")




Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top