unless it's something extreme. One possible way to stay safer wherever you are, is to never
convince yourself that it can never happen to me, or this place is safe because it looks safe.
Go wherever you want to go, do what you like, but protect yourself. SoMa has been in transition for some thirty years, and with Mission Bay booming, it's not what it used to be.
SoMa is known to be a little dicey, however. There are two public housing projects near the south slope of Potrero Hill, and the Bayview is still an area-in-transition. Both of these areas are on the southern border of SoMa, however, and the wary pedestrian can easily steer clear of any trouble.
SoMa has an undeserved reputation because of its history -- in San Francisco's early days, SoMa was a low-class industrial neighborhood. These days, it's inhabited by the young techies who work at companies such as Yelp and Zynga.
As anywhere in a city as large as San Francisco, it's best not to be out wandering aimlessly at night, but so long as you stay north of 16th street you're pretty much in the vibrant heart of the city.