creating gameobject in another gameobject

When drawing gameobjects thru scripts using lines like

GameObject x = GameObject.CreatePrimitive(PrimitiveType.Sphere);

is there away to move it into another gameobject? Like when working in the Unity’s UI, you can drag and drop a gameobject into another, can you do that thru script as well?