← Back to Previous Page

Understanding verbose in R

Ever set verbose = FALSE thinking it just quiets down your code?

That's true β€” but it can do so much more.

Here's how understanding verbose gave me full control over function output β€” and can help you debug smarter too.

🧡 1/ Let’s start with the basics:

verbose controls how much info a function prints as it runs.

Most people only use:

verbose = TRUE  # Show messages
verbose = FALSE # Be silent

But here’s what many miss πŸ‘‡

2/ Numeric levels for more control

In many R functions, verbose can take numeric levels like 0, 1, 2, or 3.

Think of it like choosing the volume of commentary your function gives.

3/ 🎚️ Verbose Levels Explained:

4/ Example:

myFunction(data, verbose = 0) # quiet
myFunction(data, verbose = 1) # normal messages
myFunction(data, verbose = 2) # detailed logs
myFunction(data, verbose = 3) # debug everything

This is useful for testing, pipelines, or debugging complex steps.

5/ πŸ“¦ In packages like WGCNA:

verbose isn't capped. You can set:

verbose = 4, 5, 6…even 7+

These unlock:

sft = pickSoftThreshold(datExpr, powerVector = 1:20, verbose = 5)

Note: verbose is not standardized β€” each function can implement it differently.

Verbose level illustration

6/ πŸ”¬ What about Seurat?

Functions that support verbose = TRUE:

NormalizeData()
ScaleData()
RunPCA()
FindNeighbors()
FindClusters()
RunUMAP()

These show status updates unless you mute them.

7/ ❌ Functions without verbose:

AverageExpression()
FetchData()
DimPlot()

No toggle β€” they just run silently.

πŸ’‘ Tip: Unsure if a function supports verbose? Try:

args(FunctionName)
# or
?FunctionName

8/ 🧠 Analogy: Verbose is like a car dashboard

You decide how much feedback you want.

9/ βœ… Key takeaways:

Ever used verbose = 2 or 3 in your code? What's your go-to level?

#RStats #Bioinformatics #Debugging #DataScience