You can set the value by string and the slug will be automatically generated:
$entry->example = "Ryan Thompson"; echo $entry->example; // ryan_thompson copy
$entry->example = "Ryan Thompson"; echo $entry->example; // ryan_thompson