G7 summit ends in escalation of a row over trade as US president attacks his Canadian counterpart on Twitter.