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

result of modelHomotypic(NULL) is 0 #211

Open
hel404 opened this issue Aug 29, 2024 · 0 comments
Open

result of modelHomotypic(NULL) is 0 #211

hel404 opened this issue Aug 29, 2024 · 0 comments

Comments

@hel404
Copy link

hel404 commented Aug 29, 2024

> modelHomotypic(NULL)
[1] 0

I've recently been using the package you developed—great work! However, when I forget to use findClusters, it still runs without errors, which prevents me from noticing my mistake.Could you please add some exception handling code?


function (annotations) 
{
    # Check if annotations is NULL or empty
    if (is.null(annotations) || length(annotations) == 0) {
        stop("Input 'annotations' cannot be NULL or empty.")
    }
    
    # Check if annotations is a vector
    if (!is.vector(annotations)) {
        stop("Input 'annotations' must be a vector.")
    }
    
    # Calculate the frequency of each annotation
    anno.freq <- table(annotations) / length(annotations)
    
    # Calculate the sum of squared frequencies
    x <- sum(anno.freq^2)
    
    # Return the result
    return(x)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant