Flexible statistical methods for estimating and testing effects in genomic studies with multiple conditions