# This script was written for data analysis reported in the manuscript: # Freshwater trematodes differ from marine trematodes in patterns connected with # Division of Labor # By Allison T Neal, Moira Stettner, Renytzabelle Ortega-Cotto, Daniel Dieringer, # and Lydia Reed # Submitted to PeerJ in October 2023 # The script was written by Allison Neal and is provided to allow easy replication # and critical evaluation of the analysis performed. The script author does not # claim to be an efficient or expert R coder, so please excuse any inefficiencies # in the code. # This script provides a list of the largest and smallest rediae for each infection, # which was used to identify rediae to be examined for the presence of appendages # and developing embryos. ### First, import data (see referenced script file for more information about data) source('/Users/aneal1/OneDrive - Norwich University/2_Research/1_Trematode Research/Div of Labor/Analysis/Redial Sizes/DOLVTsizesImportCleanUp.R') # Get a list of samples I want to look at (this is similar to levels(data$snail) but excludes # a sample number, H109, that does not have any data) samples<-c("H101","H102","H104","H107","H110","H127","H148","H156","H158","H70", "H96","P107","P112","P113","P115","P116","P117","P119","P120","P121", "P122","P125","P126","P128","P130","P131","P135","P136","P137","P139", "P140","P141","P150","P152","P153","P154","P155","P157","P160","P162", "P163","P164","P165","P166","P170","P177","P178","Ph100","Ph107","Ph109", "Ph112","Ph114","Ph115","Ph116","Ph126","Ph159","Ph95","Ph96","V141","V159", "V168","V172","V182","V183","V184") # Creates a matrix to store the sample numbers of the largest and smallest rediae bigsmall<-matrix(nrow=length(samples)*10, ncol=2) # Use a for loop to sort redia by size for each infection and save sample numbers # for the largest and smallest of each infection for(i in 1:length(samples)){ data[data$snail==samples[i],]->temp # creates a temporary subset of the data for data from a single snail temp[complete.cases(temp$lengthR),]->tempR # gets only the samples with reliable length measurements tempR[order(tempR$lengthR),]->tempR # sorts temporary data by length start<-(i-1)*10+1 # gives the first row number where the smallest and largest values should be stored in bigsmall tempR$sample[1:5]->bigsmall[start:(start+4),1] # smallest values bigsmall[start:(start+4),2]<-rep('sm',5) tempR$sample[(length(tempR$sample)-4):length(tempR$sample)]->bigsmall[(start+5):(start+9),1] #largest values bigsmall[(start+5):(start+9),2]<-rep('lg',5) } # Print list of samples to look at for comparison of morphology among largest and # smallest rediae options(max.print = 1400) # makes sure the full data set is printed in RStudio bigsmall