Team:Heidelberg/Tempaltes/iGEM42-W-18a

From 2013.igem.org

Revision as of 23:20, 4 October 2013 by JuliaS1992 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Filters fixed

The drafts for most of the filtering functions had already been implemented, but ended up non-functional. This was due to data removal using empty vectors, which produces a severe error in R. Table 1 gives an overview of the different parameters and their basic filter design.

Table 1: Overview of all filters.
Parameter Type Options* Status
Year numeric 2007-2012 final
Region string levels final
Track string levels final
Students numeric 0, 5, 10, 15, 20, >20 final
Advisors numeric 0, 2, 5, 10, 15, >15 final
Instructors numeric 0, 2, 5, 10, 15, >15 final
Biobricks numeric 0, 5, 10, 20, 50, 100, 200, >200 final
Championship character vector levels working
Regional character vector levels working
Medals string bronze, silver, medal missing
Score numeric 0-100 (steps of 10) final
Abstract binary provided/missing missing
* Levels means all possible values the parameter can have.

The general code for filtering a numerical range parameter X using R after this update is displayed below (changes are displayed in red).

FilterForX <- function(data) {
	if (input$FILX_min == ">max") data <- data[-which(data$X < max),]
	else if (input$FILX_max == ">max" & input$FilX_min != "min") data <- data[-which(data$X < input$FILX_min),]
	else if (input$FILX_max == ">max" & input$FilX_min == "min") return(data)
	else data <- data[-which(data$X < input$FILX_min | data$X > input$X_max),]
	return(data)
}

The general code for filtering a single string parameter Y using R now looks like this:
FilterForY <- function(data) {
	matchY <- rep(0, times=length(data$Y))
	for (i in 1:length(input$FILY)) {
		matchY[which(data$Y == input$FILY[i])] <- 1
	}
	delete <- which(matchY == 0)
	if (length(delete) != 0) data <- data[-delete,]
	rm(delete)
	rm(matchY)
	return(data)
}

The code for matching the awards is slighly more complicated, since the awards are saved in the data-list and we want to reduce the data-frame. This is the pseudocode for the functions:
iterate through all awards to be included {
	(re-)set a vector for deleting those items from the data-list
	iterate through all the teams in the data-list {
		if the award matches one of the team awards:
		- expand the vector for the teams to keep with the name
		- expand the vector for the teams already matched
	}
	delete those teams from the data-list, that were already positive in order to save runtime
}
reduce data-frame according to the matching result
All the filter functions and corresponding layout elements were put together in one file to easily copy and paste them to the different apps.