Skip to content
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

Create new tests #54

Open
dimalvovs opened this issue Nov 2, 2023 · 2 comments
Open

Create new tests #54

dimalvovs opened this issue Nov 2, 2023 · 2 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@dimalvovs
Copy link
Contributor

The tests present in the /tests/ seem outdated: those refer to code that does not exist (example - CoParams), to old testing data that was removed (example data/GSE98638_HCC.TCell.S5063.count.txt), as well as lack the structure. Tests need to rewritten.

@dimalvovs dimalvovs added enhancement New feature or request bug Something isn't working labels Nov 2, 2023
@dimalvovs dimalvovs self-assigned this Nov 6, 2023
@dimalvovs
Copy link
Contributor Author

  • modSim default parameters test
  • distributed parameters run test
  • useful tests from existing suit
  • github workflow for auto-testing

@dimalvovs
Copy link
Contributor Author

one problem with comparing the results on same dataset at different times (seeds) is that the ordering of rows in the resulting matrices may change. attaching a historic script used to reorder the matrices for future comparison.

# reorderByPatternMatch: function to identify corresponding rows
#                        between two P matrices
# History: EJF - original CoGAPS

# Inputs: P - matrix to be matched
#         matchTo - matrix to match P to

# Output: P with reordered rows to match matchTo

#'\code{reorderByPatternMatch} plots the output A and P matrices as a
#' heatmap and line plot respectively
#'
#'@param P matrix to be matched
#'@param matchto matrix to match P to
#'@export

reorderByPatternMatch <- function(P, matchTo) {
	
	# check that P and the matchTo matrix have the same dimensions for valid matching
	if (nrow(matchTo) != nrow(P) | ncol(matchTo) != ncol(P)) {
		stop('CoGAPS: reorderByPatternMatch: dimensions of P and matchTo must agree')
	}
	
	# ensuring that rownames match for simplicty of matching process
	row.names(matchTo) <- row.names(P)
	
	# compute the correlation between each entry
	corP <- cor(t(matchTo),t(P))
	
	# initalize the new matrix
	pMatch <- rep(0, nrow(P))
	names(pMatch) <- row.names(P)
	
	# match patterns in order of correlation
	for (p in 1:(nrow(P)-1)) {
		ptemp <- which(corP==max(corP),arr.ind=T)
		pMatch[row.names(corP)[ptemp[1]]] <- colnames(corP)[ptemp[2]]
		if (length(corP) > 1) {
			corP <- corP[-ptemp[1],-ptemp[2]]
		}
    }
    pMatch[which(pMatch==0)] <- setdiff(names(pMatch), pMatch)
	
	# return matched patterns
	return(P[pMatch,])
	
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant